Ruby Forum Rails Germany > restful

Posted by Werner Laude (Guest)
on 07.08.2008 12:10
(Received via mailing list)
Hallo..

wie bekomme ich das routing hin?

map.resources :articles, :as => 'artikel'

zeigt alle artikel im shop an etc.

jetzt will ich als admin die gleiche resource nutzen

Das hier klappt nicht:

admin.resources :articles, :controller => 'admin'

#=> undefined local variable or method `admin' for main:Object
(NameError)

Gruß 


Werner Laude
Lindenburger Allee 22  -  50931 
Köln
0221.8805 635

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

http://www.webagentur-laude.de

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Posted by Sebastian Wenzlaff (hoshbad)
on 07.08.2008 12:13
(Received via mailing list)
Hallo Werner,

sieht es bei dir auch so aus?

map.namespace(:admin) do |admin|
   admin.resources :articles
end


MFG
Sebastian
Posted by Werner Laude (Guest)
on 07.08.2008 12:32
(Received via mailing list)
Am 07.08.2008 um 12:12 schrieb Sebastian Wenzlaff:

> Hallo Werner,
>
> sieht es bei dir auch so aus?
>
> map.namespace(:admin) do |admin|
>  admin.resources :articles
> end
>


Hallo Sebastian..

danke soweit..
wenn ich jetzt admin aufrufe wird die Artikelliste dargestellt.
Nur die links (show, edit..) zeigen weiterhin auf den articles
controller.!?
link_to 'Edit', edit_article_path(article)
link_to 'Destroy', article,.....

edit_admin_path
=>undefined local variable or method `admin' for #<ActionView::Base:
0x2164c8c>

Das soll natürlich auf den admin controller zeigen..
Gruß 
Posted by Sebastian Wenzlaff (hoshbad)
on 07.08.2008 12:37
(Received via mailing list)
Hallo Werner,

> edit_admin_path
> =>undefined local variable or method `admin' for #<ActionView::Base: 
> 0x2164c8c>
>
> Das soll natürlich auf den admin controller zeigen..
rake routes


MFG
Sebastian

--
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25
Posted by Sebastian Wenzlaff (hoshbad)
on 07.08.2008 12:40
(Received via mailing list)
> edit_admin_path
> =>undefined local variable or method `admin' for #<ActionView::Base: 
> 0x2164c8c>

edit_admin_articles_path

müsste es sein.


MFG
Sebastian
Posted by Beate Paland (Guest)
on 07.08.2008 12:57
(Received via mailing list)
Hallo Werner,

2008/8/7 Werner Laude <newsgroup@wernerlaude.de>:
> Nur die links (show, edit..) zeigen weiterhin auf den articles controller.!?
> link_to 'Edit', edit_article_path(article)
> link_to 'Destroy', article,.....
>
> edit_admin_path
> =>undefined local variable or method `admin' for
> #<ActionView::Base:0x2164c8c>
>
> Das soll natürlich auf den admin controller zeigen..

lass dir mal auf der Kommandozeile "rake routes" ausgeben, dann siehst
du, wie de entsprechende Funktionaufruf lauten muss (das _path
dahinter nicht vergessen :))

GrüßeBeate
Posted by Werner Laude (Guest)
on 07.08.2008 13:02
(Received via mailing list)
Am 07.08.2008 um 12:37 schrieb Sebastian Wenzlaff:

> Hallo Werner,
>
>> edit_admin_path
>> =>undefined local variable or method `admin' for #<ActionView::Base: 
>> 0x2164c8c>
>>
>> Das soll natürlich auf den admin controller zeigen..
> rake routes

Prima tool..
zeigt mir z.B.

admin_article GET    /admin/articles/:id
{:controller=>"admin/articles", :action=>"show"}

wenn ich dann
link_to 'Show', admin_article

=> undefined local variable or method `admin_article' for
#<ActionView::Base:0x24ebcd4>

Noch was.. ;-)

controller=>"admin/articles"
Muß ich im admin Controller was ändern?

Gruß+Danke
Posted by Sebastian Wenzlaff (hoshbad)
on 07.08.2008 13:09
(Received via mailing list)
> link_to 'Show', admin_article
>
> => undefined local variable or method `admin_article' for  
> #<ActionView::Base:0x24ebcd4>
Siehe Beates Kommentar.

Vergiss das "_path" oder "_url" nicht.


MFG
Sebastian
Posted by Werner Laude (Guest)
on 07.08.2008 13:18
(Received via mailing list)
Am 07.08.2008 um 12:57 schrieb Beate Paland:

hallo Beate

>> #<ActionView::Base:0x2164c8c>
>>
>> Das soll natürlich auf den admin controller zeigen..
>
> lass dir mal auf der Kommandozeile "rake routes" ausgeben, dann siehst

da bin ich noch etwas am (ver)zweifeln..

link_to 'Show', admin_article_path
link_to 'Destroy', admin_article_path
=> admin_article_url failed to generate from
{:action=>"show", :controller=>"admin/articles"} - you may have
ambiguous routes, or you may need to supply a
und
link_to 'Edit', edit_admin_article_path(article)

zeigt auf:
admin/articles/1/edit
  ergibt:

=>uninitialized constant Admin

Hier nochmal was ich habe:
routes:
map.namespace(:admin) do |admin|
admin.resources :articles
end

admin_controller:
def show
@article = Article.find(params[:id])
end


Gruß