Forum: Rails I18n locale parameter on URL

Posted by Paulo H. V. Neves (Guest)
on 2010-04-08 23:24
(Received via mailing list)
Hello guys. I just started learning Rails and one of the first things
I was interested was the localization of my website.
I started looking the rails-i18n and it worked beautifully, except for
some things. e.g.: i wanted the url to be /en/books instead of
the locale=en, so I tried what they say on 
http://guides.rubyonrails.org/i18n.html
about the :path_prefix on routes.rb. But it just didn't worked...
Here is my routes.rb:


ActionController::Routing::Routes.draw do |map|
  map.resources :mannequins, :path_prefix => '/:locale'
  map.resources :recipes, :path_prefix => '/:locale'

  # The priority is based upon order of creation: first created ->
highest priority.

  # Sample of regular route:
  #   map.connect 'products/:id', :controller => 'catalog', :action =>
'view'
  # Keep in mind you can assign values other than :controller
and :action

  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller =>
'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions
automatically):
  #   map.resources :products

  # Sample resource route with options:
  #   map.resources :products, :member => { :short => :get, :toggle
=> :post }, :collection => { :sold => :get }

  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many =>
[ :comments, :sales ], :has_one => :seller

  # Sample resource route with more complex sub-resources
  #   map.resources :products do |products|
  #     products.resources :comments
  #     products.resources :sales, :collection => { :recent => :get }
  #   end

  # Sample resource route within a namespace:
  #   map.namespace :admin do |admin|
  #     # Directs /admin/products/* to Admin::ProductsController (app/
controllers/admin/products_controller.rb)
  #     admin.resources :products
  #   end

  # You can have the root of your site routed with map.root -- just
remember to delete public/index.html.
  map.root :controller => "recipes", :path_prefix => '/:locale'

  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.
  # Note: These default routes make all actions in every controller
accessible via GET requests. You should
  # consider removing or commenting them out if you're using named
routes and resources.
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end

but when I try to access http://localhost:3000/fr/recipes I get

ActionController::RoutingError in Recipes#index
Showing app/views/recipes/index.html.erb where line #15 raised:
recipe_url failed to generate from {:locale=>#<Recipe id: 2, ti....

Can anyone shed some light on this for me?

'-'
Posted by Andrés Mejía (Guest)
on 2010-04-09 01:29
(Received via mailing list)
Can you show me line #15 of app/views/recipes/index.html.erb?
Posted by Paulo Henrique (Guest)
on 2010-04-09 12:53
(Received via mailing list)
Line #15 contains the following:

<td><%= link_to 'Show', recipe %></td>


That's it...

Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/8 Andrés Mejía <andmej@gmail.com>
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-09 13:31
(Received via mailing list)
Can you try this:

<%= link_to "Show" recipe_path(@recipe) %>

In the conntroller show you must pass a variable named @recipe with the
object

2010/4/9 Paulo Henrique <paulodemoc@gmail.com>

> +55 38 9141 5400
>>
>>> ActionController::Routing::Routes.draw do |map|
>>> and :action
>>>  # Sample resource route with options:
>>>  #     products.resources :sales, :collection => { :recent => :get }
>>> remember to delete public/index.html.
>>>  map.connect ':controller/:action/:id.:format'
>>> '-'
>>>
>>
>
--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-09 13:34
(Received via mailing list)
Sorry are you iterating in a variable named @recipes?

In this case, the link must be this:

<% @recipes.each do |recipe| %>
   <%= link_to "Show" recipe_path(recipe) %>
<% end %>
El 9 de abril de 2010 13:29, Andrés gutiérrez 
<andresgutgon@gmail.com>escribió:

>>
>> GTALK: paulodemoc@gmail.com
>>>> I was interested was the localization of my website.
>>>>  map.resources :recipes, :path_prefix => '/:locale'
>>>>  # Sample of named route:
>>>> => :post }, :collection => { :sold => :get }
>>>>
>>>>
>>>>
>>>> --
>>>  --
>>  --
>
>
> --
> Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
>
> -----------------------------------------------------------------------------
> "Caminar sobre el agua y desarrollar software a partir de unas
> especificaciones es fácil. si ambas están congeladas."
> Edward V. Berard, ingeniero informático.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-09 13:39
(Received via mailing list)
Yeah, I am iterating... Here's the code:

<% @recipes.each do |recipe| %>
  <tr>
    <td><%=h recipe.title %></td>
    <td><%=h recipe.author %></td>
    <td><%=h recipe.description %></td>
    <td><%= link_to 'Show', recipe_path(recipe) %></td>
    <td><%= link_to 'Edit', edit_recipe_path(recipe) %></td>
    <td><%= link_to 'Destroy', recipe, :confirm => 'Are you sure?', 
:method
=> :delete %></td>
  </tr>
<% end %>

But I got the same error....

Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-09 13:57
(Received via mailing list)
Do yo have this?

# app/controllers/application_controller.rb
def default_url_options(options={})
  logger.debug "default_url_options is passed options: 
#{options.inspect}\n"
  { :locale => I18n.locale }
end

Ah! in the console put this:
rake routes

To see what is generating

2010/4/9 Paulo Henrique <paulodemoc@gmail.com>

> => :delete %></td>
> GTALK: paulodemoc@gmail.com
>>
>>>
>>>> Paulo Henrique Vieira Neves
>>>>>
>>>>>> Here is my routes.rb:
>>>>>>  #   map.connect 'products/:id', :controller => 'catalog', :action =>
>>>>>> automatically):
>>>>>>  # Sample resource route with more complex sub-resources
>>>>>>  #   end
>>>>>>  # consider removing or commenting them out if you're using named
>>>>>>
>>>>>> .
>>>>> .
>>>> .
>>> "Caminar sobre el agua y desarrollar software a partir de unas
>> "Caminar sobre el agua y desarrollar software a partir de unas
>> For more options, visit this group at
> For more options, visit this group at
> http://groups.google.com/group/rails-i18n?hl=en.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-09 14:05
(Received via mailing list)
I have that on application_controller.rb, and when I ran 'rake routes', 
I
got this:

    mannequins GET    /:locale/mannequins(.:format)
 {:controller=>"mannequins", :action=>"index"}
               POST   /:locale/mannequins(.:format)
 {:controller=>"mannequins", :action=>"create"}
 new_mannequin GET    /:locale/mannequins/new(.:format)
 {:controller=>"mannequins", :action=>"new"}
edit_mannequin GET    /:locale/mannequins/:id/edit(.:format)
{:controller=>"mannequins", :action=>"edit"}
     mannequin GET    /:locale/mannequins/:id(.:format)
 {:controller=>"mannequins", :action=>"show"}
               PUT    /:locale/mannequins/:id(.:format)
 {:controller=>"mannequins", :action=>"update"}
               DELETE /:locale/mannequins/:id(.:format)
 {:controller=>"mannequins", :action=>"destroy"}
       recipes GET    /:locale/recipes(.:format)
{:controller=>"recipes", :action=>"index"}
               POST   /:locale/recipes(.:format)
{:controller=>"recipes", :action=>"create"}
    new_recipe GET    /:locale/recipes/new(.:format)
{:controller=>"recipes", :action=>"new"}
   edit_recipe GET    /:locale/recipes/:id/edit(.:format)
 {:controller=>"recipes", :action=>"edit"}
        recipe GET    /:locale/recipes/:id(.:format)
{:controller=>"recipes", :action=>"show"}
               PUT    /:locale/recipes/:id(.:format)
{:controller=>"recipes", :action=>"update"}
               DELETE /:locale/recipes/:id(.:format)
{:controller=>"recipes", :action=>"destroy"}
          root        /:locale
{:controller=>"recipes", :action=>"index"}
                      /:controller/:action/:id
                      /:controller/:action/:id(.:format)

Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-09 14:15
(Received via mailing list)
That is correct no?

2010/4/9 Paulo Henrique <paulodemoc@gmail.com>

> {:controller=>"mannequins", :action=>"edit"}
>     new_recipe GET    /:locale/recipes/new(.:format)
> {:controller=>"recipes", :action=>"index"}
>
>> end
>>>
>>> <% end %>
>>>
>>>> <% end %>
>>>>>
>>>>>> +55 38 9141 5400
>>>>>>> paulodemoc@gmail.com> wrote:
>>>>>>>> Here is my routes.rb:
>>>>>>>>  #   map.connect 'products/:id', :controller => 'catalog', :action
>>>>>>>>  # Sample resource route (maps HTTP verbs to controller actions
>>>>>>>>
>>>>>>>> controllers/admin/products_controller.rb)
>>>>>>>>  # Note: These default routes make all actions in every controller
>>>>>>>> Showing app/views/recipes/index.html.erb where line #15 raised:
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>> To unsubscribe from this group, send email to
>>>>>> To unsubscribe from this group, send email to
>>>>>
>>>>
>>>> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
>>> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
>> -----------------------------------------------------------------------------
>> .
> .
> For more options, visit this group at
> http://groups.google.com/group/rails-i18n?hl=en.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-09 14:19
(Received via mailing list)
I think so, but doesn't change the fact that I am getting the error...

Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-09 14:57
(Received via mailing list)
Can you put the complete error please


2010/4/9 Paulo Henrique <paulodemoc@gmail.com>

>
>>>     mannequins GET    /:locale/mannequins(.:format)
>>>  {:controller=>"mannequins", :action=>"update"}
>>>         recipe GET    /:locale/recipes/:id(.:format)
>>> Att.
>>>> Do yo have this?
>>>>
>>>>>     <td><%=h recipe.author %></td>
>>>>> Att.
>>>>>>  Sorry are you iterating in a variable named @recipes?
>>>>>> Can you try this:
>>>>>>>> <td><%= link_to 'Show', recipe %></td>
>>>>>>>> SKYPE: paulodemoc
>>>>>>>>>> things
>>>>>>>>>> ActionController::Routing::Routes.draw do |map|
>>>>>>>>>>  # Keep in mind you can assign values other than :controller
>>>>>>>>>>
>>>>>>>>>>  #     products.resources :comments
>>>>>>>>>>  #   end
>>>>>>>>>>  # consider removing or commenting them out if you're using named
>>>>>>>>>> ti....
>>>>>>>>>> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
>>>>>>>>> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
>>>>>>>> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
>>>>>>> -----------------------------------------------------------------------------
>>>>>> -----------------------------------------------------------------------------
>>>>>> .
>>>>> .
>>>> "Caminar sobre el agua y desarrollar software a partir de unas
>>>> For more options, visit this group at
>>> For more options, visit this group at
>> especificaciones es fácil. si ambas están congeladas."
>> http://groups.google.com/group/rails-i18n?hl=en.
> http://groups.google.com/group/rails-i18n?hl=en.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-09 15:03
Attachment: rubyerror.png (306 KB)
(Received via mailing list)
Enclosed image:[image: rubyerror.png]
Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by StuFF mc (Guest)
on 2010-04-09 15:07
Attachment: rubyerror.png (306 KB)
(Received via mailing list)
something's wrong with your routes - show it too us. And for the love 
of...
don't paste a screenshot, use http://pastie.org/ :)
Posted by Paulo Henrique (Guest)
on 2010-04-09 15:11
Attachment: rubyerror.png (306 KB)
(Received via mailing list)
Just for you guys to check:

Routes.rb
http://pastie.org/911390

<http://pastie.org/911390>Application_Controller.rb
http://pastie.org/911392

If i should put any other files, lemme know...

Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-09 15:24
Attachment: rubyerror.png (306 KB)
(Received via mailing list)
Try this:
 <%= link_to 'Show', recipe_url(:id => recipe) %>


2010/4/9 Paulo Henrique <paulodemoc@gmail.com>

> Att.
>> something's wrong with your routes - show it too us. And for the love
>>> +55 38 9141 5400
>>>>
>>>>> SKYPE: paulodemoc
>>>>>>> routes', I got this:
>>>>>>>  {:controller=>"mannequins", :action=>"show"}
>>>>>>>    edit_recipe GET    /:locale/recipes/:id/edit(.:format)
>>>>>>>                       /:controller/:action/:id(.:format)
>>>>>>> 2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
>>>>>>>> Ah! in the console put this:
>>>>>>>>>   <tr>
>>>>>>>>> But I got the same error....
>>>>>>>>> 2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
>>>>>>>>>> andresgutgon@gmail.com> escribió:
>>>>>>>>>>> Line #15 contains the following:
>>>>>>>>>>>> MSN: paulodemoc@live.com
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Here is my routes.rb:
>>>>>>>>>>>>>>  # Sample of regular route:
>>>>>>>>>>>>>> product.id)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> remember to delete public/index.html.
>>>>>>>>>>>>>> routes and resources.
>>>>>>>>>>>>>> recipe_url failed to generate from {:locale=>#<Recipe id: 2,
>>>>>>>>>>>>>> rails-i18n@googlegroups.com.
>>>>>>>>>>>>> To post to this group, send email to
>>>>>>>>>>>> Google Groups "rails-i18n" group.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>
>>>>>>>> Groups "rails-i18n" group.
>>>>>>> Groups "rails-i18n" group.
>>>>>> --
>>>>>> To post to this group, send email to rails-i18n@googlegroups.com.
>>>>> To post to this group, send email to rails-i18n@googlegroups.com.
>>>> Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
>>>> To unsubscribe from this group, send email to
>>> To unsubscribe from this group, send email to
>> To unsubscribe from this group, send email to
> To unsubscribe from this group, send email to
> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rails-i18n?hl=en.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-09 15:28
Attachment: rubyerror.png (306 KB)
(Received via mailing list)
It worked =]

I changed

<% @recipes.each do |recipe| %>

  <tr>

    <td><%=h recipe.title %></td>

    <td><%=h recipe.author %></td>

    <td><%=h recipe.description %></td>

    <td><%= link_to 'Show', *recipe_url(recipe)* %></td>

    <td><%= link_to 'Edit', *edit_recipe_path(recipe)* %></td>

    <td><%= link_to 'Destroy', *recipe*, :confirm => 'Are you sure?',
> :method => :delete %></td>

  </tr>

<% end %>


to

<% @recipes.each do |recipe| %>

  <tr>

    <td><%=h recipe.title %></td>

    <td><%=h recipe.author %></td>

    <td><%=h recipe.description %></td>

    <td><%= link_to 'Show', *recipe_url(:id => recipe)* %></td>

    <td><%= link_to 'Edit', *edit_recipe_path(:id => recipe)* %></td>

    <td><%= link_to 'Destroy', *:id => recipe*, :confirm => 'Are you 
sure?',
> :method => :delete %></td>

  </tr>

<% end %>


Now I should make the same kind of modifications on the other views...

Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-10 08:36
Attachment: rubyerror.png (306 KB)
(Received via mailing list)
In your position i'll try this:

This solution has currently one rather big *downside*. Due to the
> _default_url_options_ implementation, you have to pass the :id option
> explicitely, like this: link_to 'Show', book_url(:id => book) and not
> depend on Rails’ magic in code like link_to 'Show', book. If this should
> be a problem, have a look at two plugins which simplify work with routes in
> this way: Sven Fuchs’s routing_filter [1] and Raul Murciano’s
> translate_routes [2].
>

This text is from rails Guides [3]

[1] http://github.com/svenfuchs/routing-filter/tree/master
[2] http://github.com/raul/translate_routes/tree/master
[3]
http://guides.rubyonrails.org/i18n.html#setting-th...


El 9 de abril de 2010 15:28, Andrés gutiérrez 
<andresgutgon@gmail.com>escribió:

>>
>>     <td><%= link_to 'Show', *recipe_url(recipe)* %></td>
>>
>>     <td><%=h recipe.description %></td>
>> <% end %>
>> SKYPE: paulodemoc
>>>
>>>> Att.
>>>>> something's wrong with your routes - show it too us. And for the love
>>>>>> +55 38 9141 5400
>>>>>>>
>>>>>>>> GTALK: paulodemoc@gmail.com
>>>>>>>>>> I have that on application_controller.rb, and when I ran 'rake
>>>>>>>>>>      mannequin GET    /:locale/mannequins/:id(.:format)
>>>>>>>>>> {:controller=>"recipes", :action=>"new"}
>>>>>>>>>>                       /:controller/:action/:id
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> <% @recipes.each do |recipe| %>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> El 9 de abril de 2010 13:29, Andrés gutiérrez <
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> +55 38 9141 5400
>>>>>>>>>>>>>>>> paulodemoc@gmail.com> wrote:
>>>>>>>>>>>>>>>>> about the :path_prefix on routes.rb. But it just didn't
>>>>>>>>>>>>>>>>> highest priority.
>>>>>>>>>>>>>>>>>  #   map.purchase 'products/:id/purchase', :controller =>
>>>>>>>>>>>>>>>>>  #   map.resources :products, :member => { :short => :get,
>>>>>>>>>>>>>>>>>  #     products.resources :sales, :collection => { :recent
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> controller
>>>>>>>>>>>>>>>>> ActionController::RoutingError in Recipes#index
>>>>>>>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Edward V. Berard, ingeniero informático.
>>>>>>>>>>>>> especificaciones es fácil. si ambas están congeladas."
>>>>>>>>>>>>> For more options, visit this group at
>>>>>>>>>>>> .
>>>>>>>>>>> -----------------------------------------------------------------------------
>>>>>>>>>>> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
>>>>>>>>>> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
>>>>>>>>> -----------------------------------------------------------------------------
>>>>>>>>> .
>>>>>>>> .
>>>>>>> "Caminar sobre el agua y desarrollar software a partir de unas
>>>>>>> For more options, visit this group at
>>>>>> For more options, visit this group at
>>>>> For more options, visit this group at
>>>> For more options, visit this group at
>>> especificaciones es fácil. si ambas están congeladas."
>>> http://groups.google.com/group/rails-i18n?hl=en.
>> http://groups.google.com/group/rails-i18n?hl=en.
> Edward V. Berard, ingeniero informático.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-10 08:37
Attachment: rubyerror.png (306 KB)
(Received via mailing list)
It worked too...
Now I am having the same error on these lines:

*<% form_for(@recipe) do |f| %>*
  <%= f.error_messages %>

=/

Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by Paulo Henrique (Guest)
on 2010-04-10 08:51
(Received via mailing list)
It worked. Now I found another problem... the "Destroy" link doesn't 
work.
It doesn't even prompt anymore, it just refreshes the index page and all 
the
recipes are still there...
The link is being generated by this:

*<td><%= link_to 'Destroy', :id => recipe, :confirm => 'Are you sure?',
:method => :delete %></td>*


Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-10 12:28
(Received via mailing list)
The solution of :id => whatever dosn't the Rails Way IMHO. You should 
try to
use the rails helpers (link_to, form_for,...) in the correct way:

<%= link_to "Show", recipe %>

To solve your problems with routes i suggess you to use some of the
solutions i recomend you in the other mail.

If you prefer my "bad" solutions to make the destroy link work, try 
this:

<%= link_to 'Destroy', recipe_path(:id => recipe) , :confirm => 'Are you
sure?', :method => :delete* *%>



2010/4/9 Paulo Henrique <paulodemoc@gmail.com>

> Paulo Henrique Vieira Neves
>> f| %>
> http://groups.google.com/group/rails-i18n?hl=en.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-10 14:08
(Received via mailing list)
I already tried this, but i still have the same.
The confirmation doesn't show and the index reloads, but with the url of 
the
destroy link...

Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-10 14:12
(Received via mailing list)
Show the generated destroy url please

2010/4/9 Paulo Henrique <paulodemoc@gmail.com>

> SKYPE: paulodemoc
>> solutions i recomend you in the other mail.
>>> It worked. Now I found another problem... the "Destroy" link doesn't
>>> Bsc. Sistemas de Informação
>>>
>>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "rails-i18n" group.
> To post to this group, send email to rails-i18n@googlegroups.com.
> To unsubscribe from this group, send email to
> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rails-i18n?hl=en.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-10 14:15
(Received via mailing list)
When I click on 'destroy', I still get to the index page, but with this 
url
on the address bar:
http://localhost:3000/fr/recipes?confirm=Are+you+s...
<http://localhost:3000/fr/recipes?confirm=Are+you+s...
Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-10 14:35
(Received via mailing list)
ok. I think you have a sintax error in the destroy link. Show me how you
write the => link_to  ,please :)

2010/4/9 Paulo Henrique <paulodemoc@gmail.com>

> SKYPE: paulodemoc
>>> The confirmation doesn't show and the index reloads, but with the url of
>>>
>>>> If you prefer my "bad" solutions to make the destroy link work, try
>>>>> work. It doesn't even prompt anymore, it just refreshes the index page and
>>>>> +55 38 9141 5400
>>>>>
>>>>
>>>> --
>>>  --
>>
>> You received this message because you are subscribed to the Google Groups
> You received this message because you are subscribed to the Google Groups
> "rails-i18n" group.
> To post to this group, send email to rails-i18n@googlegroups.com.
> To unsubscribe from this group, send email to
> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rails-i18n?hl=en.
>



--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Iain Hecker (Guest)
on 2010-04-10 15:29
(Received via mailing list)
Hi!

Be careful with your parentheses.

not:
link_to "destroy", recipe_path(:id => recipe, :method => :delete,
:confirm => t(:sure))

but:
link_to "destroy", recipe_path(:id => recipe), :method => :delete,
:confirm => t(:sure)

Cheers, Iain

2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>:
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-04-10 15:35
(Received via mailing list)
yes, i think that was the problem

2010/4/9 Iain Hecker <iain@iain.nl>

> :confirm => t(:sure)
> >> url on the address bar:
> >>
> >>>> the destroy link...
> >>>>>
> >>>>> this:
> page and
> >>>>>> MSN: paulodemoc@live.com
> >>>>>> --
> >>>>>
> >>>>> You received this message because you are subscribed to the Google
> >>>> Groups "rails-i18n" group.
> >>> Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
> >>> "rails-i18n" group.
> >> "rails-i18n" group.
> > Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
> > To unsubscribe from this group, send email to
> To unsubscribe from this group, send email to
> rails-i18n+unsubscribe@googlegroups.com<rails-i18n%2Bunsubscribe@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rails-i18n?hl=en.
>
>


--
Experiencia es lo que obtienes, cuando no obtienes lo que quieres.
Posted by Paulo Henrique (Guest)
on 2010-04-12 15:18
(Received via mailing list)
Mine was:

<%= link_to 'Destroy', :id => recipe, :confirm => 'Are you sure?', 
:method
=> :delete %>

and I changed it to:

<%= link_to 'Destroy', recipe_path(:id => recipe), :method => :delete,
:confirm => t(:sure) %>

And it worked perfectly =]

Thank you all ;)


Att.
Paulo Henrique Vieira Neves
Bsc. Sistemas de Informação
+55 38 9141 5400
MSN: paulodemoc@live.com
GTALK: paulodemoc@gmail.com
SKYPE: paulodemoc


2010/4/9 Andrés gutiérrez <andresgutgon@gmail.com>
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.