How to make link for ex: controller/action/15#comments
using CHTML::link()
how to make link without #comments, i know
Thanks
Just so the question has an answer on record:
CHtml::link( 'Link', array('news/item', 'id'=>$id, '#'=>'comments'));
Related
I'm trying to implement the new Google recaptcha in my Rails 4 app but I'm unable to get the widget to display in Haml. Basically what I'm trying to do is to make this code
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
into somehting like this:
%div{class: 'g-recaptcha' data-sitekey: 'your site key'}
The way how I try to write it above gives me an error on the data-sitekey part.
I also tried to write it like this:
%div{class: 'g-recaptcha' 'data-sitekey' => 'your site key'}
and still no luck. Has anyone attempted to do this? Apparently there is not too many stackoverflow questions or online resources dealing with this. But if someone can help me with this, I would greatly appreciate it?
*Also, what is the data-sitekey considered? It's not a class or an id. What is it? Maybe I have the formatting wrong?
This is the most concise equivalent haml:
.g-recaptcha{data: {sitekey: 'your site key'}}
Your second example would also be equivalent, but you're missing a comma:
%div{class: 'g-recaptcha', 'data-sitekey' => 'your site key'}
data-sitekey is a html5 data attribute.
html2haml can convert HTML to haml.
I have a page that lists records based on the parameters given in the search filter. I need to give a download link, wherein the current records on the page are written to a file and given as a link to be downloaded.
So to put it simple, how do I give the latest records found based on the search parameters as a download link ?
P.S : I'm using the send_file method.
You could link to the download action using a custom :format merged with the query params. Something like this:
<%= link_to "Download", posts_path(params.except("action", "controller").merge(:format => "csv")) %>
Not the cleanest example but hopefully you get the idea.
You can use CSV writer to generate the required file and give a download link to the file for users.
Thanks, Anubhaw
I need to embed a flash movie into one of the pages in my Ruby on Rails app. I've put the Flash movie into the public folder, but I'm not sure how to reference it from my page, which is located at views/controller_name/page1.html.erb. How do I do this?
Thanks for reading.
link_to, eg (assuming it's in the public folder):
<%= link_to "My Hot Link Test", "/flashmovie.swf" %>
The leading "/" isn't strictly necessary, I think.
Sorry, missed the bit where you wanted to embed it, not link to it. Contrary to the title of this question. ;-) This is one easy way:
http://agilewebdevelopment.com/plugins/flashobject
we have done this, But we have just use plan html
say your flash banner is at
/public/flash/ folder
this is nothing but plain html
If someone have a better option please let me know too
cheers
sameera
Ok, I think this is probably an easy question but for the life of my I can't figure it out. I have created a table called ugtags and in that table I have two columns (beyond the basics), 'name' and 'link'.
I am trying to allow a user to add a link to a page. Ideally they would enter the link title (name) and the url (link) and in the view it would display the title as a link to the url that was entered in the link column.
I there a way to do it by simply affecting the <%= link_to h(ugtag.name) %> code?
You should just be able to do:
<%= link_to h(ugtag.name), ugtag.link %>
See the documentation for all of the relevant options.
I am looking for a Ruby script that takes a piece of text, and makes any links click-able that show up in it... Does anyone have something like this? For example, if I wrote a comment and said "Come check out my site at http://www.example.com", then the link would be click-able like an html tag.
Thanks,
Josh
Rails has a View helper called auto_link, e.g.:
<%= auto_link("Please visit my site: http://www.example.org/") %>
would produce:
Please visit my site: http://www.example.org/
Update: You can find more information about it here.