Currently i'm developing 2 Rails::Engines 1 blog (for fun) and 1 csv importer and mapper. I made them with enginex and jeweler into a gem. I installed them locally and i included either 1 of them in an empty rails 3.x project and it's working fine!
The thing i want to do know is include both gems in 1 rails 3.x project. This all works doesn't raise any errors but here is the problem.
When i go to my "/blog" routes everything is rendered perfectly. But when i go to my "/csv" route i dont see any layouts. When i look at the development.log i see this:
Started GET "/csv" for 127.0.0.1 at Sun May 01 20:23:19 +0200 2011
Processing by CsvEngine::ImportsController#index as HTML
Rendered /Library/Ruby/Gems/1.8/gems/csv_engine-0.0.1/app/views/csv_engine/imports/index.html.erb within layouts/application (0.8ms)
Completed 200 OK in 24ms (Views: 23.1ms | ActiveRecord: 0.0ms)
This all looks fine, but i dont see any of my html. But when i put a <%= raise "hell %> inside my index.html.erb it gets raised. So i'm baffled here, both my engines work. All my rails logic works but i dont see my html inside the index.html.erb.
The strangest thing is when i include "csv_engine" gem without the blog gem in a empty rails 3 app everything works fine and i get the html views.
I even tried overwriting the views from within my empty host app e.g. app/views/csv_engine/imports/index.html.erb with some other html in it but this also doesnt work.
Does anyone has any idea what this could be?
Related
Before I start, I'd like to stress that I've looked for answers and I've tried to solve the issues by myself.
I have 2 types of controllers -
A controller with a set of methods that render JSON - works perfectly
A controller that actually renders HTML
This code is working perfectly on my local machine and the problem that I have with the second controller is on my production machine.
I've added 755 permissions to all my files but my file owner is the only user on my server which is "root". I've added the files to the www-data group though.
My controller is simple.
class AdministratorController < ApplicationController
def login
end
end
And my file is views/administrator/login.html.haml.
I'm getting an error -
ActionView::MissingTemplate (Missing template administrator/login, application/login with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
* "/var/www/sitename/app/views"
):
Try to add to your Gemfile
gem 'haml-rails'
And run bundle install.
The issue has been resolved. I'm not sure what exactly went wrong with the template but I began seeing a different error relating to compiled assets. I just recompiled the assets and restarted the server. Thanks for all your help!
I'm trying to deploy a Rails 3 app which includes jQuery Mobile. It works fine in development, and I understand that it needs to precompile the JS and CSS for production. I'm getting the following error:
Started GET "/orders/mobile" for 127.0.0.1 at Wed Jun 06 14:22:40 -0400 2012
Processing by OrdersController#mobile as HTML
Rendered orders/mobile.html.erb within layouts/mobile (642.9ms)
Completed 500 Internal Server Error in 1122ms
ActionView::Template::Error (jquery.mobile isn't precompiled):
5: <head>
6: <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7: <title>Company Orders</title>
8: <%= stylesheet_link_tag 'jquery.mobile' %>
9: <%= stylesheet_link_tag 'jquery.mobile.structure' %>
10: <%= stylesheet_link_tag 'jquery.mobile.theme' %>
11: <%= stylesheet_link_tag 'http://fonts.googleapis.com/css?family=Ubuntu' %>
app/views/layouts/mobile.html.erb:8:in `_app_views_layouts_mobile_html_erb__605278794_69818059003840'
app/controllers/orders_controller.rb:330:in `mobile'
app/controllers/orders_controller.rb:329:in `mobile'
I've read the usual stuff, but there are so many things wrong here, I hardly know where to start:
I had the JQM stuff in app/assets, but have since moved them to vendor/assets. They get seen by the precompiler -- I know because it will complain about them on various tries -- but they never seem to get precompiled (in either location).
I've tried *= require_tree ../../../vendor/assets/stylesheets in application.css. I don't really want it included in every page hit, so I'd like to include it in the layout, but I'm just trying to get it precompiled somehow.
I've tried *= require jquery.mobile[[.css].erb] in application.css.
I've tried config.assets.precompile += %w( [[./]vendor/assets/stylesheets/]jquery.mobile.* ) in config/environments/production.rb.
As a last-ditch effort, I've removed the ".erb" from jquery.mobile.css.erb, and removed the <% asset_data_uri %> tags to see if it would compile. It passes the rake assets:precompile command, but still gives me the same error.
I don't want to turn off precompiling for JQM; I want it to work. (I really need to speed this page up.) However, I can't find any guide on how to get JQM elegantly inserted into a Rails 3 app (with precompiling), and I've exhausted every avenue I can think of in trial and error. Surely someone has done this and knows the right way to go about it.
My fundamental problem here is that I need to have some assets precompiled for production, but NOT included in every page hit. Here's what I've figured out:
If I didn't mind JQM being served with every page, I could either put the files in app/assets and let require_tree . do its magic, or leave those files in vendor/assets, and require them individually in application.js. If I want to put them in vendor/assets and NOT specifically require them in application.js, I can use config.assets.paths << "#{Rails.root}/vendor/assets" in production.rb, and (apparently) require_tree in application.js will process this tree as well. This still rolls them up into the compiled application JS "ball," but leaves them distinct on the filesystem.
The proper way to incorporate jQuery Mobile for specific pages -- and keep its files separated in vendor/assets -- seems to be to use both a config.assets.paths << "#{Rails.root}/vendor/assets" directive and a config.assets.precompile += %w( jquery.mobile.* ) directive. This will get the JQM files precompiled, but NOT rolled up into application-(hash).js and application-(hash).css. (They'll be individual files in public/assets.) Then you can do specific javascript_include_tag's and stylesheet_link_tag's in a layout specially for mobile views.
Big finish: I had upgraded to Rails 3.2.5 because I saw some security report on 3.2.3. I rolled back to 3.2.3 and -- incorporating what I learned above -- I was able to finally get it working. I also tried 3.2.4. Apparently there's a regression in > 3.2.3 that interferes with precompiling.
I am having issues with Heroku and Haml, I am able to run my app on localhost no problems, all test pass to, however when I go to run it on Heroku I get the following error:
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.
I read another post on Stackoeverflow that basically said to add a .gems file and add:
haml --version '>= 2.2.0'
I did that and I'm still having the same problem, so I'm wondering what I am doing wrong.
Update: I fixed that problem had to do with cache - and Heroku being read-only however now the theme I've selected via web-app does not load up on the Heroku page it shows up on local host however correctly. I looked at the log file for Heroku and it doesn't show any errors, so is it another permission issue?
Here is the log file - https://gist.github.com/1173667
Thanks,
Looks like your stylesheets are not included as part of the layout.
Assuming your stylesheet is available as public/stylesheets/styles.css, try adding the following line inside the head tag in application.html.haml
= stylesheet_link_tag 'styles.css'
That should resolve the theming issue. If not, post the code in application.html.haml
UPDATE:
From the logs, looks like you have two layouts: layouts/sign and layout/application. If they are there for a reason, you need to address that.
Else, change your home controller to render the new layout:
class HomeController < ApplicationController
layout "sign"
end
we have developed an rails project using rails 3 and mysql, it has images, css and javascript (jquery) and it is working fine in windows xp environment.
But when i migrated the code to ubuntu, the images, css ( applies partially) and javascript (jquery) are not loading. i am running in development mode.
I have included the js and css like this:
<%= stylesheet_link_tag "jquery-one", "ctlCalendar", "application", "jquery.treeview" %>
<%= javascript_include_tag "jquery-1.6.2.min", "jquery.rails", "jquery.treeview"%>
Here the error i am getting:
Started GET "/images/LoginImage.png" for 127.0.0.1 at 2011-08-13 01:02:04 +0900
ActionController::RoutingError (No route matches "/images/LoginImage.png"):
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)
Started GET "/Images/Back_Login.gif" for 127.0.0.1 at 2011-08-13 01:02:05 +0900
ActionController::RoutingError (No route matches "/Images/Back_Login.gif"):
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.1ms)
can anyone help me to solve this problem?
Thank You,
Sudhir C.N.
Ubuntu, and other Linux versions, have case-sensitive file names, while Windows XP doesn't.
This means while LoginImage.png and loginimage.png are the same in Windows, they are not the same in Ubuntu. That's probably the cause of your problem.
The same applies to path names – /images and /Images are completely different paths in Linux, so make sure not to mix them up.
So this is what I get from looking at my production.logs from heroku:
Completed 200 OK in 63ms (Views: 6.0ms | ActiveRecord: 50.3ms)
Processing by EventsController#show as HTML
Parameters: {"id"=>"2"}
Rendered events/show.html.erb within layouts/application (3.7ms)
Completed 500 Internal Server Error in 15ms
Everything works locally and I have even pushed the database to heroku using db:push. Is there any more robust logging for heroku than the lines above that aren't helpful?
I'm sure its because you haven't ran rake db:migrate
If that does not work make sure that all the gems you need are in your Gem file, i.e. you are not making any local require statements to gems not in the Gemfile.
What I have found helpful is tailing the log.
And then you need to run this in console:
heroku logs --tail
Now click on the same page you were getting problems at before and check out the logs.
EDIT: on rails 4 you'll need to add the rails_12factor gem to get the detailed logs.
This isn't related to ruby but it might be good information for other googlers.
My issue not being able to see the actual error was that I was using a third party PHP tool that did this: # mysql_connect( ... ) which simply hides the error that that function didn't exist .. really evil code