Questions tagged [link-to]

link_to is the method in Ruby on Rails that is used to create link tags within views.

link_to is the method in Ruby on Rails that is used to create link tags within views.

e.g., With the appropriate route defined and the profile object with ID=1,

link_to "Profile", @profile

would return the HTML fragment

<a href="/profiles/1">Profile</a>

More details can be found in the Ruby on Rails API documentation.

863 questions
0
votes
2 answers

Using link_to to add object into HABTM relation table

In my application I have List objects and Problem objects, Lists are made up of Problems and problems can belong to many lists. I am using HABTM on both classes and I've created their join table like so: class AddTableListsProblems <…
0
votes
1 answer

javascript popup routes to wrong URI [rails]

I have a link_to that creates a popup. It works on some pages but when I click it on other pages it goes to the wrong URI. Is the issue with my app architecture? I want all links to route to…
Jaqx
  • 826
  • 3
  • 14
  • 39
0
votes
1 answer

link_to Helper Modifications

Inside of a rails app that I am working, I modified the link_to helper slightly: def link_to(*args, &block) args[1] = params[:client_id].present? ? "#{args[1]}?client_id=#{params[:client_id]}" : args[1] super end I did this so I…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
2 answers

Rails link_to with erg for link text

This has to be really simple but I'm stuck. I have two fields fname and lname that I want to put together and use as the link to the Show method. <%= link_to 'Show', person %> <%= link_to person.fname %> <%= person.lname %> The top line links to…
Scott S.
  • 749
  • 1
  • 7
  • 26
0
votes
2 answers

Rails: dynamic_path of link_to to different a resource name

How can I do a link_to that I can modify like the object class string? First off, I have my objects as polymorphic (book, magazine) so I need to user link_to(@object.title, [@object.user, @object]). This make's it polymorphic like user_book_path or…
index
  • 3,697
  • 7
  • 36
  • 55
0
votes
2 answers

link_to with customized devise routes

Cheers! I have in routes code like this: user_photo GET /users/:user_id/photos/:id(.:format) photos#show And I have a link_to helper: = link_to 'Show', ... How can I link it to show photo uploaded by current user? user_photo_path doesn't…
xamenrax
  • 1,724
  • 3
  • 27
  • 47
0
votes
2 answers

Rails, link_to, unable to pass on a value

I am trying to achieve an unordered list of "Categories" in which if you click on a particular Category, all the photos(jags) that belong to that Category show on the screen. My view that includes the categories is:
nupac
  • 2,459
  • 7
  • 31
  • 56
0
votes
1 answer

'wrong number of arguments (0 for 1)' error when using link_to to pass variable from view to controller

I'm trying to use link_to to pass a variable from a view to a controller. Here's what my code in the view looks like: <%= link_to 'Send Chant', :controller => 'send_chants', :action => 'index', :content => @chant.content %> Here's what the…
dougiebuckets
  • 2,383
  • 3
  • 27
  • 37
0
votes
1 answer

List Item Wrapping Link_to in Conjunction with Can

I'm trying to do something very basic but am getting tripped up. I am creating anchor tags using link_to, but I want these tags to be wrapped in li tags. I followed the steps on a previous post Rails 3: Link_to list item? but this wraps my LIs in…
edev.io
  • 560
  • 5
  • 21
0
votes
1 answer

link_to inside file inside app folder rails 3.2.8

I have a file called messages_datatables.rb inside /app/datatables/admin/ class Admin::MessagesDatatable delegate :params, :h, :link_to, :number_to_currency, to: :@view . . . private def data messages.map do |message| [ …
hyperrjas
  • 10,666
  • 25
  • 99
  • 198
0
votes
2 answers

Link_to another view ruby on rails

I am trying to use the link_to feature to link one view to another. The view i am calling link_to is app/views/instructors/show.html.erb and that snippet of code looks like this (namely, the second to last line of it) <% provide(:title,…
Layla
  • 347
  • 1
  • 6
  • 13
0
votes
2 answers

Rails - Passing parameters to create filled in form

I want to pass some parameters with link_to method to create method, so that the form will shown prefilled to a user. I wrote this code to pass the parameters, <%= link_to "Buy", new_transaction_url(:friend_id => @friend.id, :t_type => 2) %> And in…
CanCeylan
  • 2,890
  • 8
  • 41
  • 51
0
votes
1 answer

Rails helper method issue

I'm new to rails and am having what I think is a very simple issue. I have a list of "tasks". When you click on a task, I want to update its row in the database to mark it as complete (changing the "status" column form 0 to 1). Here is what the…
nathan
  • 514
  • 1
  • 7
  • 20
0
votes
1 answer

rails view link_to

Thanks for your time! I had a code :
    <% for…
mCY
  • 2,731
  • 7
  • 25
  • 43
0
votes
1 answer

link_to post ID in Rails

In my feed I have this: <%= link_to feed_item.title, @micropost %>
I cannot figure out how to make it link to the individual pages for posts. Right now it links to: http://localhost:3000/microposts…
Livi17
  • 1,620
  • 3
  • 25
  • 43