link-to

renaming routes (map, link_to, to_param) in rails

Hey there, I'm having a little issue...I setup a rails application that is to serve a german website. To make use of Rails' internal pluralization features, I kept all my models in english (e.g. the model "JobDescription"). Now, if I call "http://mysite.com/job_descriptions/", I get all my job_descriptions....so far, so good. Because I ...

Ruby on rails link_to syntax

After following a tutorial Ive found. Im now redoing it again, without the scaffolding part, to learn it better. However, editing my \app\views\home\index.html.erb to contain: <h1>Rails test project</h1> <%= link_to "my blog", posts_path> I get an error: undefined local variable or method `posts_path' for #<ActionView::Base:0x4e1d95...

(Rails) Using "link_to_remote" in conjunction with a popup/popout window...?

Hi All, What is the most straightforward mechanism by which to "link_to_remote" and popout a window with the data? I need "link_to_remote" because I need to pass certain data along with the url without redoing my routes. If this would be better served by a "link_to" without the need to redo my routes, I'm all for it. I simply can't g...

link_to from helper

Wondering how to do this. I have a month helper and want to render a list of each month. If you click on the month it would then pass the number value . I want to produce a list like this Choose a month January - February - March - April - May..... That are links. My helper looks like this. MONTHLIST = [ [ "January", "1" ], ...

Rails RESTful Routing With '/' and Slugs

I am looking to do something similar a wordpress slug where I have a URL like this while maintaining RESTful routing: http://foo.com/blog/2009/12/04/article-title The reason I am interested in keep RESTFUL routing is that I am unable to use many plugins because I am using custom routes. I have already done the RESTful appearance with:...

Ruby on Rails link_to internal id

How do i use a link_to inorder to go to a specific (html) ID on a page normally if i wanted to go to the "whatever_id" on a page i could use <a href="http://www.example.com/index/mypage#whatever_id&gt;Click Here</a> but i would like to use my link_to <%= link_to "click here" , {:action => "mypage", :controller => "index" }, :id => "...

undefined method 'link_to'

I'm writing a ruby-on-rails library module: module Facets class Facet attr_accessor :name, :display_name, :category, :group, :special ... URI = {:controller => 'wiki', :action => 'plants'} SEARCH = {:status => WikiLink::CURRENT} #Parameters is an hash of {:field => "1"} values def render_for_search(paramete...

Using link_to in a class in a Rails helper

I have a rails helper using the structore below, but when I use it I get the message undefined method 'link_to' The helper is arranged as: module MyHelper class Facet def render_for_search link_to("Value", params) end end class FacetList attr_accessor :facets def initialize #Create facets end...

Sending a variable through a link_to without url query in Ruby on Rails

Hi all, I'm trying to send a variable through a link_to, without using url query in Ruby on Rails, from one controller's index view to be used on another controller's index. Basically, I need to pass the Turma.id (school class id), to the Elementos_turma(peoples in the class) controller, so I can use it and filter the index: ElementosT...

Context-Dependent Model Defaults in Rails from link_to

What's the standard for applying default values to Rails models from links? Here's the situation: There is a model in Spree called ProductGroup, which is a collections of settings defining how to find a Product (based on a bunch of property values you set). I want to be able to use this structure for defining common ProductGroups: E...

Button_to uses POST Link_to uses GET, why? ROR

I've ran into a ror problem using the link_to. Why does my link to use the GET method and my button_to use the POST method, after I specified my "method"=>"post" within the link_to parameters? View: <%= button_to "pdf", :action => 'getquote' %> <%= link_to 'pdf', {:controller => 'inventories', :action => 'getquote', :method => :post }...

Passing optional arguments through a wrapper method in Rails

I have the following wrapper method for link_to: def link_to_with_current(text, link, condition, *args) current_class = condition ? 'current' : nil link_to text, link, :class => current_class, *args end When called with this sample: link_to_with_current 'My Link', '/mylink.html', true, :id => 'mylink' The following link is gene...

How to pass hidden parameters in "link_to"

Is there a way to pass parameters with a link_to call without it showing up on the URL? I'm making a simple star-rating system, and I'm basically making each star an image link that passes its value as a parameter to a new rendering of the same page. The helper code looks like this: def stars_generator(edit_mode = false) @rating = pa...

Rails: How do I add an additional parameter to resource-based link_to call?

I have a resource defined in routes.rb like so: map.resources :users I like using the cleanest link_to option, which would be: link_to @user I'd like to add an additional parameter to this call, though: "view=local" If I were using the user_path, I'd do this: link_to user_path(@user, { :view => 'local' }) Is there a way to get ...

ruby-on-rails: link-to using post method but parameters are in the url

I'm using link_to 'My link', path(:arg1 => session[:arg1], :arg2 => session[:arg2],:arg3 => anyobject.id), :method => :post but the html link being generate includes (arg1,arg2,arg3) as url query parameters. How can remove them? Did I miss something in the docs? Thanks ...

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

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 lin...

How to get link_to in Rails output an SEO friendly url?

Hi, My link_to tag is: <%= link_to("My test title",{:controller=>"search", :action=>"for-sale", :id=> listing.id, :title => listing.title, :search_term => search_term}) %> and produces this ugly URL: http://mysite.com/search/for-sale/12345?title=premium+ad+%2B+photo+%5Btest%5D How can I get link_to to generate: http://mysite.com/...

How to remove the action argument from Rails link_to function?

Hi, Not sure how to frame this so here goes.... I have the following link_to tag: <%= link_to("My test title",{:controller=>"search", :action=>"for-sale", :title => listing.title, :search_term => search_term, :id=> listing.id}) %> and the following custom route in my routes.rb file: map.connect ':controller/:action/:title/search_it...

link_to_unless_current for subURLs in Rails

Hey, I'm looking for a way to use something similar to link_to_unless_current but for sub URLs, so for instance for both these URLs: /entity_name/ /entity_name/123 it will not result as a link. How can I achieve that in Rails? UPD: Resolved it my own custom way, please Ruby savvy let me know if it's good. module ApplicationHelper ...

Rails Link_To doesn't add a CSS Class correctly

So I'm trying to use link_to to create a link in my Rails app and trying to add a CSS class to certain links. The problem that I have is that when I add my html options to the link_to arguments, the links don't get created and I end up with nothing. Here's my code: <%=link_to( image_tag(@beetle.icon_img, :width=>30, :alt=>"Beetle", :bor...