Why does my link_to image_tag give syntax errors in Rails app?

rails render error
render navbar rails
rails controller render partial
rails redirect to partial
rails render form from another controller
rails render partial relative path
rails erb
rails collection

I have an image and a link which work separately, but when I try to combine them they don't. I have tried many permutations of link_ to and image_tag to no avail.

separately they work fine:

<%= image_tag 'functional-med.png', class:"nutricion" %>
<%= link_to 'functional med', 'https://www.ifm.org/' %>

however when I try:

 <%= link_to 'image_tag 'functional-med.png', class:"nutricion"', 'https://www.ifm.org/' %>

i get the error: syntax error, unexpected tIDENTIFIER, expecting ')'

removing the single quotes gives the error: syntax error, unexpected ')', expecting =>

 <%= link_to image_tag 'functional-med.png', class:"nutricion", 'https://www.ifm.org/' %>

I have tried adding brackets inside and around the image_tag but keep getting syntax errors. another error I get , but dont understand is: syntax error, unexpected keyword_ensure, expecting ')'

I am not using a keyword "ensure" anywhere. I thought i was following the ruby api correctly http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

What am I doing wrong here?

Just pass a block to the link_to:

<%= link_to 'https://www.ifm.org/' do %>
  <%= image_tag 'functional-med.png', class:"nutricion" %>
<% end %>

Add class to image_tag in Rails with IF statement - css - html, I have tried these options, and they are giving me a syntax error or alt is just not do so. here is my code as of now: index.html.erb <%= link_to image_tag("new(2).​png", The form that I am working on for a rails application is using bootstrap. 2 Rails rake db:schema:load failing to run Jun 26 '18 2 Rails i18n : “fr” is not a valid locale Jun 22 '18 1 Why does my link_to image_tag give syntax errors in Rails app?

Use this:

<%= link_to image_tag('functional-med.png', class:"nutricion"), 'https://www.ifm.org/' %>

No need to add a bracket before image_tag

Exercise 6.5 bugged? Did you add the link to the destination?, I'm pretty sure I did and cannot spot if there is a syntax error, reviewed it tens of times. I tried making the link_to line of code inside an html paragraph, even storing Rails.application.routes.draw do get 'tags' => 'tags#index' get By giving the route in step 1 the name "tag", Rails automatically creates a  Create a new 5.2 app and setup ActiveStorage using a simple form as described in this blogpost; Create a new mountable engine and move the PostsController and views into the engine's namespace. Add the newly created engine to your app's Gemfile and mount the engine; Expected behavior. url_for should still work with ActiveStorage models. Actual behavior

I was working today with something like this

To mix both helpers just try

<%= link_to image_tag ('functional-med.png', class:"nutricion"), 'https://www.ifm.org/' %>

Layouts and Rendering in Rails, Layouts and Rendering in RailsThis guide covers the basic layout features of Action Controller So in this case, Rails will render the app/views/books/index.​html.erb file. This is useful for conditionally rendering static files like error pages. Asset tag helpers provide methods for generating HTML that link views to feeds,  how do you make sure that the rails application is up and running and look at the log of what requests have been made and what not by starting the server rails s. Note that only one server can be up and running at one time.

The following should work

<%= link_to image_tag("create.png"), 'http://www.google.com' %>

General link_to with image tag to a controller action

    <%= link_to image_tag("create.png"), {action: 'action_name', controller: 'controller_name'} %>

You can add class / id attribute

<%= link_to image_tag("create.png"), {action: 'action_name', controller: 'controller_name'}, class: 'some-class' %>

Display a more helpful error message when an ERB template has a , The error message refers to a syntax error in code the user hasn't written, and references This is my first time contributing to Rails, so I would certainly appreciate on the status quo; it might give the user more hints as to what is happening. .com/discourse/discourse/blob/master/app/views/layouts/​application.html.erb. So the rails_select_on_includes gem is a brilliant solution -- works perfectly! That said, agree with others that if it's this gem can do it, it really should be a supported part of AR when using eager_load. virtual_attributes (in our case, in the form of SQL DB functions) are absolutely critical.

Try this:

<%= link_to image_tag('functional-med.png', class: 'nutricion'), 'https://www.ifm.org/' %>

How to Use Rails link_to Method (With Examples), If you came here to learn about link_to & the different options you can use QUICKLY find the Ruby syntax you need, that Ruby method you're looking for or Combined with URL helpers ( _path / _url ), link_to gives you all the flexibility you need. In this example, the content of the block becomes the linking text, image or  In this tutorial you will get a Ruby on Rails Todo App up and running on your local server, and will push your work into github. If you are casually browsing and are maybe interested in doing a

The administration framework for Ruby on Rails, Built in, Active Admin has the following index renderers: end index as: :grid do |​product| link_to image_tag(product.image_path), You can also filter on more than one attribute of a model using the Ransack search predicate syntax. Filters can also be disabled for a resource, a namespace or the entire application​. Getting Started with Rails. This guide covers getting up and running with Ruby on Rails. After reading this guide, you will know: How to install Rails, create a new Rails application, and connect your application to a database. The general layout of a Rails application. The basic principles of MVC (Model, View, Controller) and RESTful design.

Chapter 5: Filling in the layout, As a first step toward adding links and styles to the sample application, we'll update the site The weird [if lt IE 9] syntax is not part of Rails; it's actually a conditional comment supported by We've given the header tag three CSS classes, called navbar The second link_to shows off the image_tag helper, which takes as  If you still see errors after re-installing, try running your application with SKYLIGHT_REQUIRED=true. This will cause Skylight to raise an exception when the native agent is missing. This exception may be useful in troubleshooting the problem. If you need help, send the exception message and backtrace to us at support@skylight.io.

The Ultimate Intermediate Ruby on Rails Tutorial: Let's Create an , If you haven't created any Rails apps with PostgreSQL yet, you may want To use ruby syntax inside the HTML file, we have to wrap it around with Since Brand is a link element, we should use a link_to method to generate links. If we visit localhost:3000/users/sign_in, we'll see that it gives us an error: In this series, you will learn how to set up a killer dockerized workflow that will raise your productivity while developing Ruby on Rails application. You will use tools like Docker, Docker Compose, Travis, and Heroku to set up a state-of-the-art workflow.

  • Imagine you're ruby. How would you take that line apart? How do you know whether this string argument goes to image_tag or link_to? Sometimes you need to use parentheses.
  • I tried: <%= link_to image_tag ('functional-med.png', class:"nutricion"), 'ifm.org' %> but got the error: SyntaxError at / syntax error, unexpected ',', expecting ')' ...mage_tag ('functional-med.png', class:"nutricion"), 'https:/... ... ^ C:/Sites/bootstrapp3/app/views/pages/index.html.erb:13: syntax error, unexpected ')', expecting :: or '[' or '.' ...al-med.png', class:"nutricion"), 'ifm.org' );
  • Give the full URL https://www.ifm.org/. Also, remove semicolon after ifm.org/;
  • class is with image, not the link.
  • I tried: <%= link_to image_tag ('functional-med.png'), "ifm.org" %> but i got the error: NoMethodError at / undefined method `symbolize_keys' for "ifm.org/":String
  • You should give the full URL <%= link_to image_tag ('functional-med.png'), 'ifm.org' %> . The ';' after 'ifm.org' is being added automatically. Ignore it.
  • Ignore the above comment by me. As you could see, <%= link_to image_tag("create.png"), {action: 'action_name', controller: 'controller_name'} %> it is expecting a hash over there. Remove the space between image_tag and ('functional-med.png') and try <%= link_to image_tag('functional-med.png'), "ifm.org/"; %>