MailingList


REST and :path_prefix

View: New views
4 Messages — Rating Filter:   Alert me  

REST and :path_prefix

by flornet@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm trying to make globalize work with rails 2.0.2 and REST.

My exemple is quite simple :

I started with a simple ressource :
map.ressource :articles

map.ressource :articles, :path_prefix => ":locale"

And as stressed by the Artweb-design guy, this would throw an error :
<%= link_to 'Show', article %>

Which we can resolve like that : 
<%= link_to 'Show', article_path(:id => article) %>


BUT

1) I've scaffolded more than 10 ressources and I would prefer not to modify every generated file in order to make links work
2) This is still an unsolved problem : 
<% form_for(@article) do |f| %>
which throws :


ActionController::RoutingError in Articles#edit

Showing articles/edit.html.erb where line #5 raised:

article_url failed to generate from {:action=>"show", :controller=>"articles", :locale=>#<Article id: 6, title: "A propos de Soy-salsero.com", seo_title: "A propos de Soy-salsero.com", [..REMOVED FOR THE EMAIL..]>}

Extracted source (around line #5):

2: 
3: <%= error_messages_for :article %>
4: 
5: <% form_for(@article) do |f| %>
6:   <p>
7:     <b>Title</b><br />
8:     <%= f.text_field :title %>

Any suggestion ? Thanks,

Florent Jaouali
--
Soy-salsero.com

Re: REST and :path_prefix

by haarts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Doesn't your form_for call need the locale as well? Something like:
<% form_for([@locale, @article]) do |f| %>

And I am skeptical about your scaffolded files. Think you need to search and replace a bit.

flornet@gmail.com wrote:
Hi,

I'm trying to make globalize work with rails 2.0.2 and REST.

My exemple is quite simple :

I started with a simple ressource :
        map.ressource :articles

Then according to http://www.artweb-design.de/2007/3/16/globalize-rails-routes-setup 
  I've made it :
        map.ressource :articles, :path_prefix => ":locale"

And as stressed by the Artweb-design guy, this would throw an error :
        <%= link_to 'Show', article %>

Which we can resolve like that :
        <%= link_to 'Show', article_path(:id => article) %>


BUT

1) I've scaffolded more than 10 ressources and I would prefer not to  
modify every generated file in order to make links work
2) This is still an unsolved problem :
        <% form_for(@article) do |f| %>
which throws :


ActionController::RoutingError in Articles#edit
Showing articles/edit.html.erb where line #5 raised:

article_url failed to generate from  
{:action=>"show", :controller=>"articles", :locale=>#<Article id: 6,  
title: "A propos de Soy-salsero.com", seo_title: "A propos de Soy-
salsero.com", [..REMOVED FOR THE EMAIL..]>}

Extracted source (around line #5):

2:
3: <%= error_messages_for :article %>
4:
5: <% form_for(@article) do |f| %>
6:   <p>
7:     Title<br />
8:     <%= f.text_field :title %>

Any suggestion ? Thanks,

Florent Jaouali
--
Soy-salsero.com

Re: REST and :path_prefix

by wowo08 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
just install one of the solutions below and you will be fine. I would recommend the one Sven has written.

http://www.artweb-design.de/2007/5/13/concise-localized-rails-url-helpers-solved-twice

Best wishes,
Roman

flornet@gmail.com wrote:
Hi,

I'm trying to make globalize work with rails 2.0.2 and REST.

My exemple is quite simple :

I started with a simple ressource :
        map.ressource :articles

Then according to http://www.artweb-design.de/2007/3/16/globalize-rails-routes-setup 
  I've made it :
        map.ressource :articles, :path_prefix => ":locale"

And as stressed by the Artweb-design guy, this would throw an error :
        <%= link_to 'Show', article %>

Which we can resolve like that :
        <%= link_to 'Show', article_path(:id => article) %>


BUT

1) I've scaffolded more than 10 ressources and I would prefer not to  
modify every generated file in order to make links work
2) This is still an unsolved problem :
        <% form_for(@article) do |f| %>
which throws :


ActionController::RoutingError in Articles#edit
Showing articles/edit.html.erb where line #5 raised:

article_url failed to generate from  
{:action=>"show", :controller=>"articles", :locale=>#<Article id: 6,  
title: "A propos de Soy-salsero.com", seo_title: "A propos de Soy-
salsero.com", [..REMOVED FOR THE EMAIL..]>}

Extracted source (around line #5):

2:
3: <%= error_messages_for :article %>
4:
5: <% form_for(@article) do |f| %>
6:   <p>
7:     Title<br />
8:     <%= f.text_field :title %>

Any suggestion ? Thanks,

Florent Jaouali
--
Soy-salsero.com

Re: REST and :path_prefix

by flornet@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Many thanks! Works great :)

Bye,

Florent Jaouali
--
Soy-salsero.com


Le 23 févr. 08 à 17:48, wowo08 a écrit :

>
> Hi,
> just install one of the solutions below and you will be fine. I would
> recommend the one Sven has written.
>
> http://www.artweb-design.de/2007/5/13/concise-localized-rails-url-helpers-solved-twice
>
> Best wishes,
> Roman
>
>
> flornet@... wrote:
>>
>> Hi,
>>
>> I'm trying to make globalize work with rails 2.0.2 and REST.
>>
>> My exemple is quite simple :
>>
>> I started with a simple ressource :
>> map.ressource :articles
>>
>> Then according to
>> http://www.artweb-design.de/2007/3/16/globalize-rails-routes-setup
>>  I've made it :
>> map.ressource :articles, :path_prefix => ":locale"
>>
>> And as stressed by the Artweb-design guy, this would throw an error :
>> <%= link_to 'Show', article %>
>>
>> Which we can resolve like that :
>> <%= link_to 'Show', article_path(:id => article) %>
>>
>>
>> BUT
>>
>> 1) I've scaffolded more than 10 ressources and I would prefer not to
>> modify every generated file in order to make links work
>> 2) This is still an unsolved problem :
>> <% form_for(@article) do |f| %>
>> which throws :
>>
>>
>> ActionController::RoutingError in Articles#edit
>> Showing articles/edit.html.erb where line #5 raised:
>>
>> article_url failed to generate from
>> {:action=>"show", :controller=>"articles", :locale=>#<Article id: 6,
>> title: "A propos de Soy-salsero.com", seo_title: "A propos de Soy-
>> salsero.com", [..REMOVED FOR THE EMAIL..]>}
>>
>> Extracted source (around line #5):
>>
>> 2:
>> 3: <%= error_messages_for :article %>
>> 4:
>> 5: <% form_for(@article) do |f| %>
>> 6:   <p>
>> 7:     Title<br />
>> 8:     <%= f.text_field :title %>
>>
>> Any suggestion ? Thanks,
>>
>> Florent Jaouali
>> --
>> Soy-salsero.com
>>
>
> --
> View this message in context: http://www.nabble.com/REST-and-%3Apath_prefix-tp14616012s17045p15653922.html
> Sent from the Globalize-rails.org mailing list archive at Nabble.com.
>