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

How to embed additional code in link_to

I'm trying to embed additional code in a link_to but not sure how to get it to work. How do I go about doing that? I'm trying to get this to work: <%= link_to image_tag("Favorite 3.png", class: "act_actions", title: "Unfavorite", alt: "Unfavorite")…
iamdhunt
  • 443
  • 6
  • 16
0
votes
3 answers

Can't delete asset for customer in Rails

Controller: def index @assets = current_customer.assets end def destroy @asset = current_customer.assets.find_by(id: params[:id]) redirect_to root_url end Index.html.erb: <% for asset in @assets %> <% assetcount += 1…
user7954
  • 323
  • 4
  • 12
0
votes
1 answer

Applying CSS for some words in a link_to link

My link is = link_to '+++ Sync categories', "cats/sync", :remote=>true And I need to apply some CSS for the part '+++' It works when I do it like this, but I have a space between the '+++' part and the rest which doesn't redirect to the…
Sammy
  • 885
  • 3
  • 13
  • 32
0
votes
2 answers

Laravel 4.1 link_to

I'm just starting with Laravel and I was doing some tutorials and crashed into something that I don't seem to work out. The thing is, I'm creating a link_to in a file like this:
  • {{ link_to("/users/{$user->username}", $user->username)…
  • lcmp
    • 117
    • 1
    • 6
    0
    votes
    2 answers

    Link_to efficiency without fetching record

    In my Rails app there are experiment instances and each experiment has attachments, which are represented as binary blobs in the database and can be quite big. This question is about efficiency in coding a link_to show the attachment. Originally I…
    NarDmw
    • 1
    • 1
    0
    votes
    2 answers

    rails link_to add post.id to href

    I'm using rails 4. Is there any way to add post.id to link_to href? <%= link_to_modal "Demo Form", "#demo-form-"+post.id, :class=>"button" %> and <%= link_to_modal "Demo Form", "#demo-form-"(post.id), :class=>"button" %> Doesn't work.
    AlexEfremo
    • 773
    • 1
    • 8
    • 20
    0
    votes
    1 answer

    The action 'create' could not be found for WatchedWatchersController

    I've searched high and low for this and the other solutions don't seem to help. The error: The action 'create' could not be found for WatchedWatchersController I get this after clicking a link made with this code in a view: <%= link_to 'Watchlist',…
    James Klein
    • 612
    • 4
    • 15
    0
    votes
    1 answer

    Rails link_to Remote Put Method Not refreshing throwing Nihlclass

    I have a Rails 3.2.14 app where I have calls, calls have units, units have statuses, and calls times in the model such as in_service_time. I'm trying to write a controller action called in_service which updates the unit's status to "In Service" and…
    nulltek
    • 3,247
    • 9
    • 44
    • 94
    0
    votes
    1 answer

    Rails link_to action, post with block

    I tried doing several searches for this and couldn't find anything, so hopefully I'm not posting a duplicate. So, the API Dock's link_to docs has this as a signature: link_to(options = {}, html_options = {}) do # name end Seemed kind of…
    kotakotakota
    • 731
    • 8
    • 26
    0
    votes
    1 answer

    Link_to with a custom method and adding html options

    Could anyone advise how to set out the following link_to please, i thought that any html option ( and that includes a class doesnt it?) should be in {}... So i have this link_to at the moment <%= link_to(@portfolio.previous_post) if…
    Richlewis
    • 15,070
    • 37
    • 122
    • 283
    0
    votes
    0 answers

    rails link_to creates unwanted confirmation message in firefox and does not work in safari

    I have the following link: <%= link_to "", skill_path(skill), :class => "button-delete", :method => :delete, :remote => true %> When the link is clicked on, the following confirmation popup appears: This web page is being redirected to a new…
    Philip7899
    • 4,599
    • 4
    • 55
    • 114
    0
    votes
    1 answer

    Rails 4.0 link_to overlaying an image with a link

    I have a thumbnail image that links to a blog post entry which is accompanied by a text title. The CSS shades the image slightly and when the user hovers over the image, it re-sizes the image slightly. The user can click on the title or on the…
    DogEatDog
    • 2,899
    • 2
    • 36
    • 65
    0
    votes
    2 answers

    Issue with newline from link_to

    In my Rails app, I was having issues with rendering a link_to because, for some reason, a new line is added through my link_to. For example, when I try to create the link with: <% byline = render :partial => "projects/author_byline", :locals =>…
    scientiffic
    • 9,045
    • 18
    • 76
    • 149
    0
    votes
    1 answer

    How to bind the Enter key to a link_to tag in Rails?

    I have several link_to tags on an ERB page styled as buttons with Bootstrap (btn class). How can I bind the Enter key to one of them?
    ilovebigmacs
    • 983
    • 16
    • 28
    0
    votes
    1 answer

    How can I link the show url to my model's title in Rails 4?

    In my Rails 4 app, I have the following code that grabs all the books from the database and displays them, with the Show link last: <% @books.each do |book| %> <%= book.title %> <%= book.author %> …