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

How can I use link_to to create a "blank" link in Rails 2.3.11?

I just want to create a link that does nothing when it is clicked (other than the jQuery code I am binding to the link's ID. I am returning "false" in my Javascript function that is bound to the links, but I would just like the link to be "#" or…
RubyRedGrapefruit
  • 12,066
  • 16
  • 92
  • 193
0
votes
1 answer

How to prefix http to multiple columns' url input from users in Rails?

This question has answered the question for a single column but how do you do it for multiple columns? I've got three columns (website, fb, twitter) that I want to prefix with http in case users don't input them in the form. I tried this but it…
hsym
  • 4,217
  • 2
  • 20
  • 30
0
votes
2 answers

Rails - custom action in controller - how to reference in view?

I'm using a custom action to get the id of a project into the session, so that only relevant info for that project is shown in other areas. I've made a custom action in the projects controller, and am having trouble getting a link to work in the…
ecs
  • 708
  • 1
  • 14
  • 33
0
votes
1 answer

Using a div for the name parameter in Rails' link_to_if method

I'm trying to make it so if a user has accepted an invite, they have the option of clicking the not_attending div to cancel the invite. However, I'd like the not_attending div to remain present even if a user hasn't accepted an invite, just without…
Adam Templeton
  • 4,467
  • 7
  • 27
  • 39
0
votes
2 answers

Why can't rake routes be more helpful

When you type rake routes in the shell it displays a nice list of routes: new_edition GET /editions/new(.:format) editions#new edit_edition GET /editions/:id/edit(.:format) editions#edit edition GET …
akkdio
  • 573
  • 2
  • 5
  • 13
0
votes
3 answers

Rails link_to_if Class Doesnt Display Correctly

For the life of me, i cant figure out why this problem is happening. I used the link_to helper all the time, but iv only used the link_to_if helper a few times, and this time I cant get the link to take a CSS class. Here's my link <%=…
Cheyne
  • 1,964
  • 4
  • 27
  • 43
0
votes
2 answers

Rails 3: AJAX call not refreshing div with link_to

I'm using Rails version 3.0.9 and jquery. The problem is that when you click on the link, the div is not updated. There are two actions: "show" and "time". Initial position - show. Controller code was (ajax_controller.rb): class AjaxController <…
OLMER
  • 117
  • 1
  • 1
  • 8
0
votes
1 answer

rails, how to pass a variable from a link_to helper

in my routes.rb i have match "monsters/:category" => "monsters#index" i have a bunch of links such as Water Fire Earth Flying however im having trouble passing "Water" or "Fire" as the :category for my routes. how exactly do i do that? i tried…
Sasha
  • 3,281
  • 7
  • 34
  • 52
0
votes
1 answer

How to make table row to work as hyperlink in Ruby on Rails?

how to make the rows of my user index view which i generated using scaffolding, to work as a hyperlink to the show user action. after clicking anywhere on the user row it will show us the corresponding user. it is also acceptable if i can make link…
Super Engineer
  • 1,966
  • 1
  • 13
  • 21
-1
votes
1 answer

Injecting values into all link_to method calls in Ruby on Rails

I have a strange requirement that I need to inject a value at the beginning of all local links. This is a legacy app and is quite large so I'm looking to do it under the hood, maybe with a monkey patch. Basically if I have a link_to "Go to…
-1
votes
1 answer

Why are my links not working for my ruby on rails site? Links stay on same page when clicked on

My links aren't working for my ruby on rails site. When I click the link the site stays on the same page. I'm following code from a book called: "RailsSpace: Building a social networking site with ruby on rails" By Michael Hartl. The book is…
-1
votes
1 answer

Rails form_with to link_to

I have a form_with like this: = form_with model: product.product_posts.new do |f| = hidden_field_tag :container, '#related-products-list' = f.hidden_field :product_id = f.hidden_field :post_id, value: @post.id = f.submit "+", class: "btn…
-1
votes
1 answer

Rails generates correct URL but always loads first Record

I have an application with a Bill ActiveRecord model. I want to include on a page a link "Back to bill", which will send the user to the "show" page of that bill. Right now I have <% link_to "Back to bill", bill_url(bill_id) %> Where bill_id is…
Leland Reardon
  • 135
  • 2
  • 12
-1
votes
3 answers

Link_to action in controller rails 5

I have this action in the controller families def hello end With view hello.html.erb hello world In the view of index in the same controller i have <%= link_to 'hello', families_hello_path %> In my routes.erb i make this post …
massi
  • 11
  • 1
  • 6
-1
votes
1 answer

How to add data-webm-clickable in link_to rails

I want to add data-webm-clickable in link_to I tried link_to(link_hash[:title],link_hash[:path].to_s, data: { webm-clickvalue: link_hash[:class]}) link_to(link_hash[:title],link_hash[:path].to_s, data: { webm: {clickvalue: link_hash[:class]}}) But…
Haseeb Ahmad
  • 7,914
  • 12
  • 55
  • 133