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
0 answers

Force rails to ignore "real" path in link_to

I am using rails on an Apache server. I can't install my rails app on the public root directory. So I have it on /web. With an .htaccess I rewrite any URL from / to /web. For example /something will be /web/something and so on. Now, in my app, I…
pzin
  • 4,200
  • 2
  • 28
  • 49
0
votes
4 answers

Simple Rails issue about link_to

I have code that looks like this that I need to understand: In this code, what is menubar.yes.okay and where is that defined? Similarly, where is…
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
0
votes
1 answer

URLs wrongly formatted when sending emails. Rails 3.2

I have managed to send emails (gmail) from my Rails 3.2 application with no apparent problems. However, the urls genrated in email have the :id param wrongly positioned. NotificationMailer default :from => 'no-reply@someDomaiin.com' def…
0
votes
1 answer

Empty item at end of .each loop because of rails cycle method

I have this list that should show all activities inside a category, and it sort of works but the last element that is displayed is strange. There are 4 activities in the DB for this particular category and at the end of the list I'm getting an item…
user393964
0
votes
2 answers

user_path(user) undefined local variable or method `user'

I'm trying to add a Profile page for the users of my App. I followed railscasts 250 & 274 to set up my user authentication & added the below to get a user profile. users/show.html.erb
Holly
  • 7,462
  • 23
  • 86
  • 140
0
votes
1 answer

Rails link_to parameters dictating flow of control in controller

So I've been struggling a little in trying to understand exactly what I can do with a link_to in Rails. Some of what I've found is old, some is new, some is very different looking from what I've got. Specifically I'm trying to have two links in a…
MCP
  • 4,436
  • 12
  • 44
  • 53
0
votes
1 answer

Why are my HAML named routes empty?

I'm trying to create some pages in HAML, which are partly working. The HTML that it produces is correct, apart from one thing. Where I have: %ul#menu %li = link_to 'Home', root_url I am expecting to get back: Home Instead,…
PaReeOhNos
  • 4,338
  • 3
  • 30
  • 41
0
votes
1 answer

on link_to click replace a section content with ajax

I have this link in view/users/show: <%= link_to "Photos (#{@user.photos.count})", user_path(@user), id: "photo_link", remote: true %> Now when I click the above link I want to change [1..6] to [1..-1] without rerender in view/users/show:
Jaqx
  • 826
  • 3
  • 14
  • 39
0
votes
2 answers

How can i add parameter to the given url which is dynamic in rails

I have page having url http://localhost:3000/athletes/list When user search on this page it changes to something like http://localhost:3000/athletes/list?first_name=sachin&last_name=tendulkar Where first_name and last_name are the search…
Salil
  • 46,566
  • 21
  • 122
  • 156
0
votes
2 answers

Rails 3.2.7 and link_to

First of all, pretty new to Rails. I've been following a tutorial on using the 'link_to' command - basically, I have some links with text 'About Us', 'FAQ', 'Contact Us', and I want them to link to their respective pages. Following the tutorial, the…
CHarris
  • 2,693
  • 8
  • 45
  • 71
0
votes
1 answer

Pass dropdown value to link_to

I have a number of link_tos, which are used to create records in the database based on the current user. I would like the current user to able to add records on behalf of other users - ex by adding a dropdown menu, where the current user can pick…
Twiddr
  • 297
  • 1
  • 4
  • 18
0
votes
3 answers

What objects should be passed to a link_to with triple nested route?

What objects should I pass to my link_to for a triple nested route? I want to retrieve the exercise show page. show.html.erb - workouts <%= link_to exercise.name, plan_workout_exercise_path(???) %> routes.rb resources :plans do resources :workouts…
neverbendeasy
  • 968
  • 10
  • 17
0
votes
1 answer

Controller action doesn't run with link_to function

I need to call a simple controller action through my view using link_to. In preferences > index.html.erb: <%= link_to "My link", :controller => :preferences, :action => :produces_text %> Note, I have also tried index.html.erb with this format…
dblarons
  • 123
  • 2
  • 11
0
votes
5 answers

Controller and action within link_to image_tag don't execute controller code

My link_to looks like this: <%= link_to image_tag(user_likes_selection.page_picture, :image_id => user_likes_selection.id, :controller => :preferences_controller, :action => :checked_average_with_profile) %> My controller,…
dblarons
  • 123
  • 2
  • 11
0
votes
1 answer

Click pictures and update database row on rails

I need to be able to click an image (out of a bunch of images) and update a profile table based on the image clicked. List of images in my view: <% @pages_selection.each do |pages_selection| %> <%= link_to…
dblarons
  • 123
  • 2
  • 11