none this are getting precompiled in the production environment, I tried rake assets:precompile, but still having this problem. someone help please !
<%= javascript_include_tag "jquery", "application" %>
<%= stylesheet_link_tag "datatable_page" %>
<%= stylesheet_link_tag "datatable_table" %>
<%= javascript_include_tag 'jquery.dataTables.min' %>
<%= stylesheet_link_tag 'gmaps4rails' %>
the problem here was, in my application.js file the require_tree was last line, I moved it to the top and the problem was solved. and for all the style sheets I included them in my application.html.erb separately. Since my application is small it was not an issue, I wouldnt recommend this though
Related
It's a constant headache when dealing with websockets, and it kills my performance in addition to adding bugs. Since ActionCable is the whole reason I upgraded I'd very much like to get rid of it completely.
The following was copied from here. It's for Rails 4, but I believe the steps are the same.
Remove the gem 'turbolinks' line from Gemfile.
Remove the //= require turbolinks from app/assets/javascripts/application.js.
Remove the two "data-turbolinks-track" => true hash key/value pairs from app/views/layouts/application.html.erb.
Edit: As of at least Rails 5 the last step should refer to "data-turbolinks-track" => "reload" as opposed to "data-turbolinks-track" => true. Thanks to #boddhisattva
Edit: As of at least Rails 4.2 you can generate a project without turbolinks to begin with. Just use something like this:
rails new my_app --skip-turbolinks
Removing //= require turbolinks from app/assets/javascripts/application.js seems to have done the trick.
I also removed both turbolinks references in app/views/layouts/application.html.erb
If you are using Webpacker (Rails 5-6)
Delete this line from Gemfile and run bundle:
gem 'turbolinks', '~> 5'
Run yarn remove turbolinks
Delete this line from application pack file app/javascript/packs/application.js:
require("turbolinks").start()
Remove any data-turbolinks data attributes from your html.
Change:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
to
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_pack_tag 'application' %>
you can also do it when you create your rails application by using;
rails new app name --skip-turbolinks
Completely removing the turbolinks tags from application.html.erb might break CSS and JS. add this lines instead of the turbolinks if no CSS or JS is loaded:
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
I have a link_to in a partial that generates a different URL when the page is accessed as the root then if it is accessed using controller/index. When accessed as the root, the URL the link_to generates has "assets" prefixed to it, which doesn't work.
Can anyone explain why this happens?
Rails 3.2.1
Ruby 1.9.3
With some help from the Rails IRC channel, I found the problem. I was not using the helper paths in the link. In case it will help someone else, here is what I did to fix it;
not working when at the root;
<%= link_to 'Gifts detail', :controller => 'gifts', :action => 'index'%>
working anytime;
<%= link_to 'Gifts detail', gifts_path%>
Hey I have seen several posts on this, but I am still having issues with calling :method => 'delete' and getting directed to the show method of my controller. The destroy method is working as expect, in that it deletes the comment, but after the request is done, it throws a 404 on GET. Here is the code:
<%= link_to 'delete', "/events/#{#event.id}/comments/#{comment.id}.js",
:confirm => 'Are you sure?',
:method => :delete,
:remote => true %>
Here is the controller method:
def destroy
#comment = #event.comments.find(params[:id])
#comment.destroy
redirect_to do |format|
format.html # redirect_to #event, :notice => "comment deleted" }
format.js { render 'destroy.js.erb' }
end
end
I've hear that this could be due to not using button_to, but I have tried using button_to as opposed to link_to but this does the same thing.
I've also heard that this could be do to some problems with the way you are using jquery in your set up, but I feel like I doubt that, but here is how I call in jquery just in case (application.html.erb):
<%= javascript_include_tag 'jquery-1.5.2.min.js', 'rails', 'application' %>
<%= javascript_include_tag 'jquery-ui-1.8.17.custom.min.js' %>
When i watch rails server output I see that it's says:
Redirected to http://0.0.0.0:3000/events/1/comments/35
Completed 302 Found in 132ms
ACTION NAME application
Started GET "/events/1/comments/35" for 127.0.0.1 at Wed Feb 08 16:31:43 -0800 2012
AbstractController::ActionNotFound (The action 'show' could not be found for CommentsController):
Thanks for the help!
Rails 3.1 and greater cleans a lot of this up for us...rails.js is gone. Jquery_ujs is part of the gem, but the file should NOT be in your javascript directory:
specifically, my jquery_ujs file was old and still "living" in my assets/javascript directory. It still had .live methods which are deprecated. Delete the file!!
Keep the gem 'jquery-rails', '~> 2.1' # REF: https://github.com/rails/jquery-ujs
Keep the //= require jquery and //= require jquery_ujs and //= require_tree .
In your application.js file
Make sure you update the gem and bundle install to get the latest gem.
If a javascript error is thrown as was the "sneaky" case for me, the rest of link_to js will not work. Now the delete and the confirmation dialog are working fine. An old jquery_ujs was the culprit.
I would make sure you have the proper version of rails.js in your app. rails.js is what now takes care of making sure delete links actually use the delete method, so you may need to update your rails.js file. What version of rails are you running?
It might be an issue with your config/routes.rb file. If an earlier entry in the routes.rb file matches events/:id/comments/:id and points to comments#show, it could cause this error.
format.html might cause it.
Change this line with
format.html { render :nothing => true }
I install and configure "Active Admin" to my rails app. It works fine on two of my computers, but not work at my production server. I have this error both in production and development (FreeBSD server):
Started GET "/admin/login" for 192.168.0.1 at Wed Oct 26 22:12:53 +0300 2011
Processing by ActiveAdmin::Devise::SessionsController#new as HTML
Rendered /usr/local/lib/ruby/gems/1.8/gems/devise-1.4.9/app/views/devise/shared/_links.erb (2.2ms)
Rendered /usr/local/lib/ruby/gems/1.8/gems/activeadmin-0.3.2/app/views/active_admin/devise/sessions/new.html.erb within layouts/active_admin_logged_out (44.7ms)
Completed 500 Internal Server Error in 169ms
ActionView::Template::Error (can't convert Sass::Rails::Importer into String
(in /usr/home/url.od.ua/app/assets/stylesheets/active_admin.css.scss)):
6: <title><%= [#page_title, active_admin_application.site_title].compact.join(" | ") %></title>
7:
8: <% ActiveAdmin.application.stylesheets.each do |path| %>
9: <%= stylesheet_link_tag path %>
10: <% end %>
11: <% ActiveAdmin.application.javascripts.each do |path| %>
12: <%= javascript_include_tag path %>
app/assets/stylesheets/active_admin.css.scss:1
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.6ms)
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.7ms)
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (10.4ms)
All gems installed! Any ideas?
I had the same problem. Updating haml gem solved it:
gem 'haml', '~> 3.1.3'
I have recently encountered into a weird problem or Rails 3, possibly ever since the new rubygems 1.5 update. Basically when I deploy my program to nginx with passenger 3.0.2, I have 500 page immediately and problems like this in my production log:
ActionView::Template::Error (couldn't parse YAML at line 105 column 13):
10: </div>
11: <% end %>
12: <div class="field">
13: <%= f.label :name %> <%= f.text_field :name %>
14: </div>
15: <div class="field">
16: <%= f.label :password %> <%= f.password_field :password %>
app/views/sessions/new.html.erb:13:in `block in _app_views_sessions_new_html_erb___4159562374589718885_19217640_4456777064017176818'
app/views/sessions/new.html.erb:5:in `_app_views_sessions_new_html_erb___4159562374589718885_19217640_4456777064017176818'
It looks like it's missing something in the environment and so it can't recognize all of my form_for elements. Basically the page is just a simple login page with 2 fields - name and password. This problem also happens for other pages with forms, but only in production environment. In development environment, it's totally working fine. I have upgraded all my gems to the latest version, including rails 3.0.4, which however looks like not quite related to this problem. I also used to deploy the same thing onto the ubuntu on my VMware BEFORE gem 1.5, everything is still fine now, however there's no turning back for the new deployments.
I have deployed this to 2 machines running latest ubuntu, and both machine have such errors. Nginx and passenger are installed with the standard steps. Obviously with this problem the site can never run. Can anyone provide any bug fix for this? Thanks very much if you could!
PS: the login page I wrote is basically from here:
http://railstutorial.org/chapters/sign-in-sign-out#top
I added the following two lines to the config/boot.rb file and the problem was solved.
require 'yaml'
YAML::ENGINE.yamler= 'syck'
I had the same problem. Actually I only needed the first line:
require 'yaml'
No need to set the YAML::Engine specifically.
For a problems with yaml syntax options like 'View/Show invisibles' in TextMate may be very helpful to locate syntax problems, yaml is very sensitive about it.
In my case I just had to replace all tabs with spaces in all locale files.
Also notice, if you don't have nodes with the same name on same level.