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 4 update user profile by button

hy, i'm trying to update a single field in a user resouce. The field to update is 'locale', it is a string type. i have triend with a form and it works: <%= form_for current_user do |f| %> <%= f.select :locale, [['En', 'en'], ['It', 'it']]…
user1066183
  • 2,444
  • 4
  • 28
  • 57
0
votes
2 answers

Nested Partial form Edit Link_to Rails

I've been staring at this for hours and I know it only a tiny error somewhere but I don't know enough to see it yet. I used this website to create the first part of the blog and for the last 3 hours I've been trying to add an edit link so users can…
0
votes
2 answers

Ruby-on-Rails convert variable to link_to array param

I have a action edit_multiple which takes a list of id's a such: def edit_multiple @products = Product.find(params[:product_ids]) end and a routes.rb: resources: products do collection do post :edit_multiple end end and a collection of…
user2732663
  • 833
  • 2
  • 10
  • 18
0
votes
2 answers

Pass two parameters with Rails/Link_to/Haml/turbo-links

I'm trying to pass two parameters, data-no-turbolinks and mobile This works: (1) %a{href: "#{test_path}", data: { no: { turbolink: true }}} %span Test which translates to Test Now I need to…
user1781626
0
votes
3 answers

Can't get link_to_unless_current to work

After someone pointed link_to_unless_current out to me, I would like to apply it to my dashboard sidebar. However, I can't get it to work, so I'm guessing I'm doing something wrong. This is my current sidebar .dashboard_bar %ul = link_to…
Rvervuurt
  • 8,589
  • 8
  • 39
  • 62
0
votes
2 answers

link_to path ActiveRecord call

I have users and projects, and I'm trying to create a link to the project by searching for the project using an ActiveRecord call. This is my link_to: <%= link_to "Project ABC" User.first.projects.where('title' => 'Project ABC') %> I know that this…
Jack
  • 5,264
  • 7
  • 34
  • 43
0
votes
1 answer

How to add form parameter in Rails link with PUT method?

Right now, I have the following and it works: <%= link_to 'stop service', service_path(:id => @service.id, 'service[stopped]' => true, method: :put, data: { confirm: 'Are you sure?' } %> The link looks like this:…
at.
  • 50,922
  • 104
  • 292
  • 461
0
votes
1 answer

Rails Link_to is linking to undesired view

My link_to in my view is going to a completely different "show.html.erb" than I'd like it to. I'm basically trying to understand why the "link_to @exhibit is linking to an "Investigation" profile. I think it may have to do with my routes file or…
BB500
  • 549
  • 2
  • 6
  • 24
0
votes
1 answer

How to pass parameters through link_to and have them as preset values in a form_for?

I am a beginner with rails and would really appreciate some guidance! Here is my Link_to in my first view: <%= link_to micropost.user.name, micropost.user %> | <%= link_to "Send Message", new_conversation_path( target: micropost.user.name, reason:…
0
votes
1 answer

Rails Javascript Link_tos

In my rails app i have these two link_to which both obviously do something. When i <% if Excont.where(:user_id=> current_user,:movie_id => @movie.id,:actionall => '2').includes(:user).all.count == 0%> …
PMP
  • 231
  • 6
  • 25
0
votes
2 answers

Should this link_to code work? Ruby/Rails 4.0 and 2.0.0

I apologize if this is a poor question to ask, but I'm using Rails 4 and Ruby 2.0.0 to go through a tutorial that is taught in a slightly older version. I know I shouldn't do that... but I kinda am doing that anyway. :) In the tutorial, he's…
john
  • 123
  • 2
  • 12
0
votes
2 answers

HAML link_to is not clickable

I'm very new to haml, i need it to do rails project. I don't understand why this code does not provide clickable link in the header of column. For example: %table#movies %thread %tr %th <%= link_to "Name", :sort => "name" %> …
user2628519
0
votes
1 answer

Internationalization of rails 3 app

Using this guide I am Internationalization my app. Everything works fine except that I can't change locale from default en to lv using link_to parameters. So my code is like this. Inside application layout <%= link_to image_tag ('eng.png'), :locale…
Edgars
  • 913
  • 1
  • 19
  • 53
0
votes
1 answer

How do I link_to VIEW a pdf resource (NOT download) in a custom engine on RefineryCMS?

I'm a novice RoRr and I'm building my company's website on RefineryCMS. I've properly created an engine for my Boss' publications, within which I included a pdf:resource column and have uploaded all the articles to my backend. Everything works -…
cjl
  • 1
  • 1
0
votes
2 answers

Creating a delete route for page controller

I have an application that creates page templates. There are many pages (user templates) in a User's account. I am getting the following error when I click my delete button: browser: Routing Error No route matches [DELETE] "/pages/1" html: <%=…
andy4thehuynh
  • 2,042
  • 3
  • 27
  • 37