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

Rails - passing parameters in link_to to hidden form field for id

I've got an application where the user can set up a folder to keep notes in. What I had previously was a hidden form field to store the id of the person who created it, i.e.: <%=f.hidden_field 'user_id', :value => current_user.id %> However, I now…
ecs
  • 708
  • 1
  • 14
  • 33
0
votes
1 answer

Rails link_to for other user's account

I have an app set up where a user can nominate a keyholder who will have read-only access to some of their account. The keyholder is just a user with a keyholder boolean field set to true. They also have an access_id equal to the user_id of the…
ecs
  • 708
  • 1
  • 14
  • 33
0
votes
1 answer

Routing error even if routes exists

This is really weird. I am getting a routing error on a link_to that exists on every page This is my route resources :users do member do get :creations_tab, :path => '/creations' end which translates to creations_tab_user_path GET …
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
0
votes
1 answer

Link_to in Rails. Link to displayed customized

I have an application, that takes a path of a file from the database and renders it to html and displays. The controller, view and routes look like the following: project/index.html.erb

<%= link_to project.title,{:controller => "markdowns" ,…

dora
  • 1,314
  • 2
  • 22
  • 38
0
votes
1 answer

Why is Rails executing action on refresh without clicking the link

I have been trying to find this answer everywhere online without luck, maybe this will help someone else. I installed a ruby gem called socialization, which works fine.. it allows users to follow/unfollow/like/unlike/mention anything. the issue I am…
0
votes
1 answer

link_to, view, controller

I implemented this link: View:
  • <%= link_to "Trainer-Sportler", :controller => "trainerones", :action => "trspmatch" %>
  • controller: def trspmatch render :trspmatch end and one view trspmatch.html.erb Rails says: Unknown action The…
    ubuseral
    • 427
    • 1
    • 3
    • 14
    0
    votes
    1 answer

    Rails Dynamic variable at link_to with JS

    I have form to showing all list from some filter form with js and also another button that direct to another action on the same controller BUT still carry the value of the form filter. For the js things had done properly, but for the the other…
    ksugiarto
    • 940
    • 1
    • 17
    • 40
    0
    votes
    1 answer

    Ruby on Rails Custom link_to

    I have a list posts, which when clicked on should show the url as posts/this+is+the+title. After doing this, how would I catch this in the controller to fetch data from the database? <% @posts.each do |fq| %> <%= link_to fq.title,fq%> …
    dora
    • 1,314
    • 2
    • 22
    • 38
    0
    votes
    1 answer

    How to call method with params with link_to - rails 3

    I have a model named School and I have a method called custom_search: def self.custom_search( text, page, order = :asc ) search( include: [:prices] ) do fulltext text paginate page: page, per_page: 7 order_by :price, order …
    user592638
    0
    votes
    1 answer

    Using a named route to generate a simple link using my match route format

    Here are the routes I've written: Foo::Application.routes.draw do get "home/index" match "/ads/:category_name" => "ads#by_category" match "/ads/:category_name/:id" => "ads#show" resources :ads root :to => 'home#index' end In one of my…
    sergserg
    • 21,716
    • 41
    • 129
    • 182
    0
    votes
    1 answer

    I filter items using a check_box_tag helper, how do I accomplish the same filtering using the link_to helper?

    I have a page where I need to send parameters so that the url looks like this: /my_controller?stores%5BStoreName%5D=1 However, when I try to form my link_to I get this url: /my_controller?stores%5B%5D=5BStoreName&stores%5B%5D=1 This is the link_to…
    Ecnalyr
    • 5,792
    • 5
    • 43
    • 89
    0
    votes
    1 answer

    Rails Simple Routing

    I can't understand why this simple routing isn't working right now. The link below doesn't work: it gives routing error No route matches [DELETE] "/questions" <%= link_to 'delete', @question, :method => :delete, :action => :destroy %> rake routes…
    Maximus S
    • 10,759
    • 19
    • 75
    • 154
    0
    votes
    1 answer

    link_to current page rails

    I was wondering what the syntax is to link to an attribute on the same page I have a list of dates
      <% @response.each_pair do |date, movie| %>
    • <%= link_to date_format(date), date, :class => 'scroll_to' %>
    • <% end %> …
    Richlewis
    • 15,070
    • 37
    • 122
    • 283
    0
    votes
    2 answers

    Simple routing in Rails

    I'm trying to destroy a link from a User Show view. So from /users/1, I want to access destroy action in teacher_student_links controller. The first attempt: <%= link_to 'destroy', :controller => "teacher_student_links", :action => "destroy", :id =>…
    Maximus S
    • 10,759
    • 19
    • 75
    • 154
    0
    votes
    1 answer

    Button_to with text and image rails 3

    How to create a button with label and image in Rails3? This code only show an image: <%= link_to image_tag("newRevision.png"), {:controller => :review_transitions, :action => :show_step}, {:class => "navBtn"} %> but... the image with text? <%=…
    user1364684
    • 800
    • 2
    • 8
    • 28