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
1 answer

How to make image_tag hyperlink using link_to in Rails, with mouseover?

I am placing *image_tag* images within *link_to* elements, as well as trying to do a mouseover image swap. It's all working except for the mouseover, which is not grabbing the alternate image. On a more general note, am I doing hyperlinked images…
pete
  • 2,739
  • 4
  • 32
  • 46
0
votes
1 answer

Rails Favorites Model Association, link_to not producing html

I am trying to implement a favorite relationship in my Ruby on Rails app. The route, controller, and relationship all appear to be working but link_to "favorite" is not working, by which I mean it is not even producing the html link, though it is…
0
votes
1 answer

Call JQuery function after link to a page

For my navigation bar, I have it so that when I click on one of the items, my css class "current-menu-item" is activated. This works to a certain extent. My Jquery code is as follows: $(document).ready(function(){ $("li.menu").click(function(){ …
Vasseurth
  • 6,354
  • 12
  • 53
  • 81
0
votes
5 answers

Ruby on Rails link_to

I am using link_to with some HTML elements and this is what I have : <% link_to "", { :controller => "posts" }, :id => "posts", :class => "read-more" %> But I want it that it will link to the posts with the id that each post has, any help would be…
user1602683
  • 33
  • 1
  • 5
0
votes
1 answer

link_to update for a nested resource not working

The link in _applicant.html.erb looks like this in the browser: http://localhost:3000/needs/3/applicants.1 and when clicked on this shows up in the browser: Routing Error No route matches [PUT] "/needs/3/applicants.1" I want it to update the…
Pavan Katepalli
  • 2,372
  • 4
  • 29
  • 52
0
votes
1 answer

Ruby on Rails: link_to :remote=> true still navigating.

I'm new to rails, and I'm trying to perform an ajax request. Correct me if I'm wrong, but as I understand it, requests are supposed to be performed with a link_to using :remote true. I have this line of code, which links to the desired page: …
HashFail
  • 536
  • 1
  • 5
  • 14
0
votes
2 answers

How to pass id from link_to to locals?

I m passing the id from link_to to locals. But it is not able to find the result, saying cannot find article without id. I need to pass the id for display articles in modal. <% @articles.each do |a|%>

<%= link_to a.title, {"data-toggle" =>…

Ahmad hamza
  • 1,816
  • 1
  • 23
  • 46
0
votes
1 answer

Link_to helper method to include icon within a element

Here's what the default scaffolding generates: <%= link_to 'Delete', admin_user, method: :delete, data: { confirm: 'Are you sure you want to delete?' } %> I want to create a helper method so that I can call a remove_link(admin_user) and have it…
sergserg
  • 21,716
  • 41
  • 129
  • 182
0
votes
2 answers

Rails, named route with regexp doesn't work

I have following problem and I can't understand why it's doesn't work: I have routes: get "/:id" => 'landings#show_direct', as: :direct_landing, id: /ticket-from-[a-zA-Z0-9_]+/ get "/:id" => 'landings#show_reverse', as: :reverse_landing, id:…
the-teacher
  • 589
  • 8
  • 19
0
votes
1 answer

Ruby on Rails: Linking to resource show page results in No Route Matches

I have been working on my first project in rails and have stumbled across a problem while using tags. I have it working so when the user clicks a tag it shows all entries associated with that tag. However when I try to make those names link to the…
Monty Monro
  • 603
  • 2
  • 10
  • 22
0
votes
1 answer

Setting a value sent from a link_to a partial in another view

So i have this link from a partial in a view: <%= link_to 'Inscribir Ejemplares en la Carrera', home_carreras_path(@race, :meeting_id => meeting.id) %> That link sends me to another view where two other partials are rendered. The browser…
Saul
  • 69
  • 6
0
votes
1 answer

How to pass the UI control values as the parameters to the Controller in Rails?

I met a problem of parameter passing in Rails. I have an object named 'account' and another object named 'locale'. There is a one-to-many relationship between them. One locale can be mapped with multiple accounts. On accounts/index.html.erb, I have…
0
votes
1 answer

undefined local variable or method on link_to in rails

Thats the link_to <%= link_to('Dashboard', dashboard_index) do %> <% end %> Thats the corresponding rake routes entry. dashboard_index GET /dashboard/index(.:format) dashboard#index What could be wrong? Any…
Denny Mueller
  • 3,505
  • 5
  • 36
  • 67
0
votes
1 answer

How to implement this nested linked_to_function?

In my view I want the user to be able to browse a catalog of products. The hierarchy is as following: Category Product AdditionalInfoForm In my main view I render a partial for the categories: #opContent = render :partial =>…
r712m
  • 299
  • 3
  • 7