Route missing when using jquery-ui on ror project
I'm trying to use the button widget of jquery-ui in my ror project.
I added the jquery-1.5.1.min.js file in the public/javascripts folder, and included it in the application.html.erb file as below:
#application.html.erb
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag "jquery-1.5.1.min" %>
<%= javascript_include_tag "jquery-ui-1.8.14.custom.min" %>
Then one of my routes stops working.
# routes.rb
c开发者_如何学编程ontroller :sessions do
get 'login' => :new
post 'login' => :create
delete 'logout' => :destroy
end
#application.html.erb
<%= link_to image_tag("Arrow Left 2.png"), logout_path, :method => :delete, :class => "barlink" %>
The button effect works, but When I click on the logout link, it gives the following error:
Routing Error
No route matches "/logout"
I also tried to switch the order of the scripts as:
<%= javascript_include_tag "jquery-1.5.1.min" %>
<%= javascript_include_tag :defaults %>
For this case, the route works, but my button effect disappears.
Any idea?
<%= link_to {:controller => 'sessions', :action => "destroy"}, :method => :delete, :class => "barlink" do %>
<%= image_tag("Arrow Left 2.png") %>
<% end %>
I've problem similiar like you and solve by that snippet code... may it help you, thx
Solved.
add the following line in GemFile
gem 'jquery-rails'
run
sudo bundle install
run
rails generate jquery:install -ui -force
then i can either use the jquery-min provided or the jquery-1.5.1.min without any problem.
精彩评论