link-to

rails 4 with link_to and method post with strong parameters

和自甴很熟 提交于 2020-01-02 04:44:06
问题 I'm stuck in a problem which can't be that complicated, but I'm just not getting things right. Assuming I've got two Models: class Notification < ActiveRecord::Base belongs_to :device validates :number, presence: true end and class Device < ActiveRecord::Base belongs_to :user has_many :notifications, :dependent => :destroy //rest omitted for brevity end with nested routes like so: resources :devices do resources :notifications end and a notifications controller like so: class

Every link_to on my rails 4 application is being called twice

时间秒杀一切 提交于 2020-01-01 10:46:08
问题 I'm experiencing some unusual behaviour with my Rails 4 Application. Every single-time I click on a link_to inside my views, my controllers actions are being called twice. For example: In my root_url I have this standard call for users_profile : <%= link_to('User Profile', users_profile_path, :class => "logout-button") %> When I click this link, my console shows the following output: Started GET "/users/profile" for 127.0.0.1 at 2013-11-25 20:45:53 -0200 Processing by Users:

undefined method 'link_to'

∥☆過路亽.° 提交于 2020-01-01 04:04:11
问题 I'm writing a ruby-on-rails library module: module Facets class Facet attr_accessor :name, :display_name, :category, :group, :special ... URI = {:controller => 'wiki', :action => 'plants'} SEARCH = {:status => WikiLink::CURRENT} #Parameters is an hash of {:field => "1"} values def render_for_search(parameters) result = link_to(display_name, URI.merge(parameters).merge({name => "1"})) count = WikiPlant.count(:conditions => (SEARCH.merge(parameters.merge({name => "1"})))) result << "(#{count})"

Ruby on rails 3 link_to controller and action

别说谁变了你拦得住时间么 提交于 2019-12-30 02:33:06
问题 I know this is probably a pretty simple concept. I am trying to create a link to a controller and action. For example I have a link in my layout file to update a record when a link is clicked, so I need to be able to link to the controller and action. How would I accomplish this? 回答1: link_to "Label", :controller => :my_controller, :action => :index See url_for. 回答2: Also with CSS: <%= link_to "Purchase", { :controller => :transactions, :action => :purchase }, { class: "btn btn-primary btn-lg

Rails 2 to Rails 3 : using link_to instead of link_to_remote (including remote and update)

99封情书 提交于 2019-12-28 06:23:45
问题 A quick and easy answer I'm sure. I'm upgrading a Rails project from version 2 to version 3 and replacing a load of the link_to_remote with link_to's as per the Rails 3 update. Even something as simple as : <%= link_to "Check Time", {:action=>:get_time}, :remote=>true, :update=>'current_time' %> <div id='current_time'></div> doesn't seem to work. The request (using get method) is going through ok and the rendered html is : <a href="/monitoring/get_time" data-remote="true" update="current_time

ruby on rails link_to an image

可紊 提交于 2019-12-28 05:52:55
问题 I'm facing the following problem: I have a very small image gallery with image files located in the following directories app/assets/images/locale/thumbs/ app/assets/images/locale/big/ I have to create a hyperlink that as a content has a thumb image and as a target - its bigger version from app/assets/images/locale/big/ folder: <a href="path-to-full-size-image-001.jpg"> <img alt="first photo preview" src="/assets/locale/thumbs/001.jpg" /> </a> I'm doing this by means of = link_to(image_tag(

rails link_to tag to build join record in rails

核能气质少年 提交于 2019-12-25 04:19:46
问题 I'm trying to build a form that allows a user to add products to an order. The way I have it setup so far is that a user will select from 2 dropdown boxes and type into 1 text field 1 - the product they want 2 - its size 3 - the quantity they want. What I hope to do is have the user click a link_to tag to "Add" this item to their order. I was thinking I could do this via ajax and build the associative record in my controller and have it render on the page when the request returns. When the

Rails 3.1, can't make link_to image_path?

核能气质少年 提交于 2019-12-24 19:15:13
问题 I want to make a fairly straightforward image link that uses an image from my assets. Getting weird errors. First I tried: <%= link_to assets_path "town.png", 'index' %> and got the error Started GET "/" for 127.0.0.1 at Wed Nov 30 17:27:10 -0500 2011 Processing by PagesController#intro as HTML Rendered pages/intro.html.erb within layouts/application (114.9ms) Completed 500 Internal Server Error in 124ms ActionView::Template::Error (undefined method `assets_path' for #<#<Class:0x10fdc4898>

How to link to a pdf from a png with Rails?

我与影子孤独终老i 提交于 2019-12-24 12:28:23
问题 I have an image of a map.png file on part of a page. I would like this image to be clickable, and then to download the pdf version of that image. I've been using this as a reference Rails 3.1, can't make link_to image_path?, but I'm not sure how to proceed. It looks like I also need to edit something with the way the page is routed. Thanks for all the help! 回答1: Do you have a route to the pdf download or is the file itself a static asset? You can use a standard link_to helper with an image

How to generate custom sorted query string URL in Rails link_to?

♀尐吖头ヾ 提交于 2019-12-24 08:25:42
问题 When I use link_to helper in Rails 3.0.7 app with many parameters, it generates a lexicographically sorted url as probably mentioned in the to_param method for Hash in Activesupport documentation. e.g. link_to "my Link", {:u=>"user", :q=>"some query", :page=>"4"} generates "/search?page=4&q=some+query&u=user" but what i want is "/search?u=user&q=some+query&page=4" Anyone able to do custom sorting as supplied in the params hash to link_to or url_for ? Unless I am missing something, this seems