link-to

“render :nothing => true” returns empty plaintext file?

谁说我不能喝 提交于 2019-11-28 15:21:56
I'm on Rails 2.3.3, and I need to make a link that sends a post request. I have one that looks like this: = link_to('Resend Email', {:controller => 'account', :action => 'resend_confirm_email'}, {:method => :post} ) Which makes the appropriate JavaScript behavior on the link: <a href="/account/resend_confirm_email" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute

How do I defined a variable link_to to an external URL

こ雲淡風輕ζ 提交于 2019-11-28 08:03:33
On my site a user has a personal profile with a link to his personal external website. The url of the sites I store in a postgresql database under the name website . When I test the result, I always get a url like this: http://localhost:3000/www.example.com instead of http://www.example.com My view index.html.erb looks like this: <% provide(:title, 'All projects') %> <h1>All projects</h1> <%= will_paginate %> <ul class="microposts"> <%= render @microposts %> </ul> <%= will_paginate %> and my _micropost.html.erb like this: <li> <span class="title"><%= micropost.title %></span> <span class=

link_to syntax with rails3 (link_to_remote) and basic javascript not working in a rails3 app?

自作多情 提交于 2019-11-28 01:43:25
问题 i am wondering if the basic link_to syntax is completely broken in current rails3 master or if i am doing some wrong syntax here. = link_to "name", nil, :onlick => "alert('Hello world!');" should actually produce an alert on click. very simple. does not work on my rails3 project! (also no error output!) any ideas? for the general link_to syntax i could not find an example where i could combine a link_to_remote with a confirmation, remote and html class (see my try below) = link_to "delete", {

link_to delete url is not working

本小妞迷上赌 提交于 2019-11-27 22:00:24
I have the following link_to delete url in my app <%=link_to "Delete",blog_path(@blog.id), :method => :delete, :class => "delete", :confirm => "Are you sure ?"%> It does not seem to be working.When I click this url, it just takes me to the show path.Can someone please tell me how to fix this. Thanks. Sean Ahrens Are you using jQuery? If so, I think the problem could be that you are using jQuery without the updated rails.js file. Download rails.js here: https://github.com/rails/jquery-ujs/raw/master/src/rails.js Drop it in your javascripts directory, overwriting the rails.js that comes default

ruby on rails link_to an image

独自空忆成欢 提交于 2019-11-27 21:24:22
I'm facing the following problem: I have a very small image gallery with image files located in the following directories app/assets/images/locale/thumbs/ app/assets/images/locale/big/ I have to create a hyperlink that as a content has a thumb image and as a target - its bigger version from app/assets/images/locale/big/ folder: <a href="path-to-full-size-image-001.jpg"> <img alt="first photo preview" src="/assets/locale/thumbs/001.jpg" /> </a> I'm doing this by means of = link_to(image_tag("locale/thumbs/001.jpg"), "locale/big/spizzicaluna001.jpg") In fact I have tried many variants for the

Why Rails “link_to” does not work for delete action?

ⅰ亾dé卋堺 提交于 2019-11-27 18:06:03
问题 In index.html.erb I display all products, and next to each product I have Edit and Delete actions: <% @products.each do |product| %> ... <%= link_to("Edit", edit_product_path(product.id), :class => 'action') %> <%= link_to("Delete", product, :method => :delete, :class => 'action') %> ... <% end %> The Edit link works ok. However, the Delete link does not work. I get the following error: Unknown action The action 'show' could not be found for ProductsController I guess it is because the

Rails link_to with inline styling

风流意气都作罢 提交于 2019-11-27 15:34:37
问题 I must change a link_to tag color without using a CSS class, how can I do? I've tried something such as <%= link_to item.description, {}, {:style=>'color:#FFFFFF;', :class => "css_class"} %> but it doesn't works on ruby 1.9.2 and rails 3.1 回答1: How about <%= link_to item.description, nil, {:style=>'color:#FFFFFF;', :class => "css_class"} %> ...or... <%= link_to item.description, '#', {:style=>'color:#FFFFFF;', :class => "css_class"} %> 回答2: This should work with Rails 3 link_to item

The better way to pass the foreign_key value to the Rails controller

半城伤御伤魂 提交于 2019-11-27 15:20:44
It's been almost a week since I've began to dig deeper in forms , associations , hashes , symbols... But it seems I cannot solve the puzzle without your help . I am working on a project for displaying different galleries content . The basic idea is when the user sees the names of galleries (names are links ) to be able to click on chosen one. Then all the images ,that belong to this gallery , are displayed . On the bottom there should be a link "Add image in this gallery" . My models : class Gallery < ActiveRecord::Base attr_accessible :name has_many :pictures end class Picture < ActiveRecord:

How to use the link_to helper to open a popup?

℡╲_俬逩灬. 提交于 2019-11-27 14:01:40
问题 I just want to use link_to to open a popup. I tried something but it doesn't work: <%= link_to 'Create a new company', new_company_path, :popup => ['create_company', 'height=600, width=600'] %> <br/> Any idea? Thanks! 回答1: My first stab at this problem would probably look something like this. It assumes you're using rails 3, jQuery and jquery-rails. If you're not, this approach definitely won't work. This exact code isn't tested, so your mileage may vary. I'm just trying to give you an idea

Using Rails link_to for links that post

放肆的年华 提交于 2019-11-27 11:44:47
I have a link that I need to submit a post request with. Normally, I'd use jQuery and prevent the link's default behavior and then submit a form to the destination. This seems like something Rails should be able to help me out with. Sure enough, the link_to method has an option for specifying a POST http method: link_to "Profile", 'http://example.com/profile', method: :post That works, but I need to add 2 parameters too. I tried: link_to "Profile", 'http://example.com/profile', method: post, param1: 'value1', param2: 'value2' That just added those parameters to the <a> HTML element, but didn't