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

Rails setting :format in (ActionController)_path( @user, format: => "csv" )?

I am following a rails cast to add in the ability to download a csv for different content in our admin area. I have the file downloading when I go to the url, so I am trying to set up the link for it now and I am running into problems trying to set…
Alan DeLonga
  • 454
  • 1
  • 10
  • 27
0
votes
2 answers

Sending a variable through a link_to without url query in Ruby on Rails

I'm trying to send a variable through a link_to, without using url query in Ruby on Rails, from one controller's index view to be used on another controller's index. Basically, I need to pass the Turma.id (school class id), to the…
Muralha
  • 23
  • 4
0
votes
1 answer

rails link_to image rather than root

I have a fancy box gallery on an index page. The gallery consists of the instance @gallery which is a model for all images that are supposed to be in the gallery. The gallery shows once a link is clicked. I also have three studios on that specific…
user2184718
  • 675
  • 1
  • 12
  • 30
0
votes
0 answers

link_to post method in rails

how to create link_to become method post in rails?, i try to send params to controller via link to. i have route like this : match '/create_session_upload_pdf_id' => "dashboard#create_session_upload_pdf_id", :as => "create_session_upload_pdf_id", …
tardjo
  • 1,594
  • 5
  • 22
  • 38
0
votes
1 answer

Rails: link_to parameters

I am completely new to Rails and still have a problem with sending parameters through this link from the ListaUsuarios View, despite trying and researching for many hours now: <%= link_to "Agregar", @solicitud_contacto, method: :post %> It does go…
0
votes
2 answers

How to redirect from view in sinatra

I need to make a link in haml view that will redirect to another page on clik. In rails I could use helper link_to signup_url, 'Sign up!', but I don't know how to make it in sinatra. So, can anyone tell me how?
Danny Ocean
  • 1,081
  • 2
  • 14
  • 30
0
votes
2 answers

Ember - Adding an extra action for #link-to

I have a simple Ember application where I have a dynamically generated list of links-to. On a single click per link, I show some detail about the clicked item. I also want to add "ondblclick" event to the link-to. Is this at all possible? If not,…
user2917629
  • 883
  • 2
  • 15
  • 30
0
votes
2 answers

Ruby link_to options

I need to add an id element into a session array in my rails application. I have the id when I bring up this view, product.id, and i have my session, called session[:cart], waiting for input. I want to push that id into the session when I click on…
0
votes
1 answer

Ruby on Rails Route not found with button_to, but not with link_to

I have a problem with routing in my app, but i do not understand why. I hope someone can explain me why this is so. thank you very much for help. <%= link_to 'Show', restaurant_path(restaurant), :id => 'button_show_restaurant', :class => 'btn…
damir
  • 1,928
  • 1
  • 16
  • 26
0
votes
0 answers

How to call a nested controller function from a view?

NodeController: def show def toggle run some stuff here end other random show stuff end I want to call the "toggle" function using a link on my show.html.erb view. How would I go about creating a link_to…
wolf2600
  • 5
  • 2
0
votes
1 answer

Non Mass assignable field in view

Iam kinda stuck at this problem. Trying to update a non mass-assignable attribute in the job model from an admin view. I need a button which trigger an action method in the admin controller which just changes job's isactive value to true. In admin…
0
votes
2 answers

link_to passing query parameter

Need to be able to generate the following URL string http://localhost:3000/admin/cities?q%5Bprovince_id_eq%5D=1&commit=Filter&order=city_name_asc how does this link_to need to be setup? link_to(p.cities.count, admin_cities_path)
Qaiser Wali
  • 358
  • 5
  • 21
0
votes
2 answers

Rails link_to the records of a instance variable .count() result

I have records in my Submitter model being shown in Application Index view being displayed in a table like below. Only I want to be able to click on the number that's listed for the .count() and be taken to my Tickets Index view with all of the…
Devin
  • 1,011
  • 2
  • 14
  • 30
0
votes
1 answer

How do I avoid leaving the Rails page on a link click?

I have a link in a Rails view such that when it's clicked on, I want it to call a particular method but NOT leave the page. I can get it to call the method but it always looks for a non-existent template. I was told something like this would be…
shiggity
  • 531
  • 4
  • 12
0
votes
2 answers

Rails Copy Button Error

I have an object "device" that contains a good deal of attributes. When editing one of the devices, I want to to have a copy button that when pressed will create a new device and load its "edit page" with the old devices parameters filled into the…