how do put %span inside rails link_to in haml - ruby-on-rails

font awesome inside link_to helper with haml
how should I do?
i have this code
.link_header
{link_to_ledger(current_ledger) span.icon-flag }
help please

Just pass span as block to link_to helper method something like following:
.link_header
= link_to_ledger(current_ledger) do
span.icon-flag

There are two options for link in rails
As simple
= link_to 'my link text', controllers_path
As you want to do
.link_header
= link_to_ledger(current_ledger) do
%span.icon-flag
-# you can also do what ever you want here even table/images can also be added

Related

Combine link_to and simple_format in rails

in Rails I have to create an hyperlink using link_to.
I would like to introduce \n in the text of this hyperlink and to make it working I have to use the function simple_format. How can I concatenate the two? I tried only in the text but it doesn't work. If I put it around the whole link_to, I got an error.
You can pass a block of code to the link_to method like:
link_to(options = {}, html_options = {}) do
# name
end
Inside the block of code you can add the logic you need for the text of the link.
PD: please add your current code to the question

Adding hyperlink in mail

My requirement is to add a link to mail sent from application developed in Ruby On Rails. Clicking that link in mail need to route user to that particular record in the application.
Can someone please help me with this some sample code.
In your view template use _url. E.g.:
<%= link_to 'Edit User', edit_user_url(#user) %>
it will return the complete URL.
You can use a simple link_to method in the mail or you could use a simple anchor tag. The latter you would have to build up.
If you need information on how to build links and paths check the rails guides. This has an example on the first section of the guide.
e.g. <%= link_to 'Patient Record', patient_path(#patient) %>
Besides this you need to provide more information if you want more help.
If you are starting with Ruby On Rails I would recommend looking at the videos on rails cast.
For your email problem you can look at sending-html-email
Also in the email I like to use the link_to helper like this
<%= link_to 'Click Me', something_url(#user.id), %>
I hope that this works. And Happy Coding

link_to in liquid template

I am new in Ruby on rails and facing issue while creating link_to using Liquid gem. I want to create a link in the email template like:
{{link_to 'Submit', profile_accounts_url(:account_id => account.id)}}
However, link is not created in email template. Please help me. Thanks in advance.
I didn't use liquied before, but you can check the syntax for link_to here.
using Liquid variables inside of a liquid tag call
http://richonrails.com/articles/liquid-templating-engine
However, I think you're using rails' syntax for link_to instead of liquid's syntax. Maybe you should just use something like:
<%= link_to "Submit", profile_accounts_path(account) %>
which will redirect to the show page.

rails combine the mail_to and button_to together

In rails, now I have mail_to, it shows up purely as a link, when i click on it, it leads me to my email application. how can i change it to a button using twitter bootstrap?
now i have
= mail_to #my.email, "#{#my.name}",:subject=>#my.email_subject
Anyway to change the link appear as a button?
I tried out the following
= button_to #my.email, "#{#my.name}",:subject=>#my.email_subject
but it still doesnt work....
You should use = mail_to #my.email, "#{#my.name}",:subject=>#my.email_subject, :class => 'button'
Hence, you must have some CSS which defines the class button.

How do I make an image link tag using haml in Rails?

I have something like this in application.html.haml:
#header
= image_tag("header.jpg")
How do I make that link to www.google.com, for example?
Thanks
I do it this way:
= link_to image_tag( 'header.jpg'), 'http://www.google.com'

Resources