link-to

Rails remote link not working when loaded via AJAX

北城以北 提交于 2021-01-28 06:12:08
问题 I guess this question is similar to this one, but asking again as it has not yet been answered. In my rails application, I have a view that contains a list of links that load content via ajax. Here is the partial for the link <%= link_to(story.title, {:controller=>"story", :id=>story.id}, :remote => true , :method=>'get', :class=>'story-link') %> This remote link works fine and loads content via AJAX when the view is loaded via HTTP. The view also has a small remote form which upon submission

How to link_to a show page from another MVC?

半城伤御伤魂 提交于 2020-03-05 07:28:27
问题 I get this error when I pull up http://0.0.0.0:3000/activities: ActiveRecord::RecordNotFound in ActivitiesController#index Couldn't find Valuation with 'id'= Line: @valuation = Valuation.find(params[:id]) activities_controller def index @activities = Activity.order("created_at desc").paginate(:page => params[:page]) @valuation = Valuation.find(params[:id]) end activities/index <% @activities.each do |activity| %> <%= render "activities/#{activity.trackable_type.underscore}/#{activity.action}"

Link_to for static pages

让人想犯罪 __ 提交于 2020-01-14 05:00:06
问题 I have made a forum-based website, I want to add a few links to my footer like "more about badges" or "how to ask questions". Well, they are static pages so I really don't want to go through controller to go to those pages. For example, I'd like to view views/static_pages/badges.html.erb using link_to or other possible tag. How can I go directly to some page in my views? 回答1: For static pages you should check out high_voltage gem. Once it's installed, it'll make a folder pages inside your

Rails RESTful Routing With '/' and Slugs

↘锁芯ラ 提交于 2020-01-12 21:24:37
问题 I am looking to do something similar a wordpress slug where I have a URL like this while maintaining RESTful routing: http://foo.com/blog/2009/12/04/article-title The reason I am interested in keep RESTFUL routing is that I am unable to use many plugins because I am using custom routes. I have already done the RESTful appearance with: map.connect '/blog/:year/:mon/:day/:slug', :controller => 'posts', :action => 'show', :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/, :slug => /.+/,

Rails RESTful Routing With '/' and Slugs

笑着哭i 提交于 2020-01-12 21:24:17
问题 I am looking to do something similar a wordpress slug where I have a URL like this while maintaining RESTful routing: http://foo.com/blog/2009/12/04/article-title The reason I am interested in keep RESTFUL routing is that I am unable to use many plugins because I am using custom routes. I have already done the RESTful appearance with: map.connect '/blog/:year/:mon/:day/:slug', :controller => 'posts', :action => 'show', :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/, :slug => /.+/,

Rails 3 - link_to with image_tag + text

大城市里の小女人 提交于 2020-01-11 22:51:29
问题 <%= link_to ((image_tag 'image.png'), url_for({:controller => 'controller_name', :action => 'action_name'}), :class => 'quick', :remote => true) %> This part of code will generate me image.png as a link. I would need to this image append some text (image + text), I tried something like a: <%= link_to ((image_tag 'image.png', 'text'), url_for({:controller => 'controller_name', :action => 'action_name'}), :class => 'quick', :remote => true) %> And similar ways, but each of these attempts ended

rails link_to :remote

只谈情不闲聊 提交于 2020-01-10 06:30:09
问题 I have the following: <%= link_to my_path, method: :delete, confirm: 'Delete?', class: 'link-delete', 'data-message' => 'Are you sure?', 'data-severity' => 'danger', :remote => true do %> <i class="icon-trash"></i> <% end %> which brings up a Bootstrap Modal for confirmation, and I wanted to hook onto the ajax call that so that I can display a spinner or some kind of text. I know that I can use unobtrusive javascript to listen to the click event like so, if I DON'T use ':remote => true' in my

passing a parameter to the link_to method

旧城冷巷雨未停 提交于 2020-01-03 17:07:44
问题 How do you pass a parameter through the MVC using the link_to method? view: <%= link_to "Remove Tag", remove_tag_issue_path(issue)%> How do I use the link_to method, to utilize the remove_tag action? issues_controller.rb def remove_tag(parameter) @issue.remove_it(parameter) end issue.rb def remove_it(parameter) self.users.delete(User.find(parameter)) end 回答1: In controller def remove_tag @issue.remove_it(params[:my_param]) end And in view <%= link_to "Remove Tag", remove_tag_issue_path(issue,

Ruby on Rails: Why the confirmation message does not appear in “link_to('delete', …)”?

空扰寡人 提交于 2020-01-03 02:10:25
问题 I have the following link next to one of my products: <%= link_to("Delete", {:action => 'destroy', :id => product.id}, :class => 'action', :confirm => 'Are you sure?') %> but when I click it, the confirmation box does not appear. The generated HTML is: <a data-confirm="Are you sure ?" class="action" href="/products/destroy/48">Delete</a> Please advise. 回答1: <%= link_to("Delete", product, :method => :delete, :class => 'action', :confirm => 'Are you sure?') %> check your javascript_include_tag

How to fix broken devise routing under journey 1.0.4

二次信任 提交于 2020-01-03 00:45:11
问题 I began troubleshooting my "sudden" broken routes problem in this SO question: Devise /users/sign_in redirecting to wrong controller and with help I was able to isolate the issue to the upgrade from journey 1.0.3 to 1.0.4 that occurred when I updated to rails 3.2.7. As you know, we need to be at rails 3.2.8, to apply important security fixes, but this means I must use journey 1.0.4, which breaks my devise routes. For instance, my custom new_user_session route is welcome#welcome, but it is