I'm doing a blog engine in rails 2. I used the restful resources
approach to create my initial 'post' and 'comment' models, and it is
working very nice.
However, I'm stuck with two problems, and I want to resolve them with
the "Rails way" :-)
* How to disable some verbs from the restful interface?
You know, people should not be able to POST or DELETE on my blog
posts. However, it doesn't seem pretty to me to go to the
PostController and simply delete those methods, because the routes
still appear and can be called (resulting in a beautiful error). How
should I deal with this? Should I change the methods to return an
error instead?
* How to make an admin area and keep DRYing?
After creating all my models, I now need an Admin area just to simple
scaffold, creating posts and comment approval. But how do I do this
and keep DRY? On one hand, I want to keep the admin area under the '/
admin' prefix. But on the other hand, I don't know how can I keep
using the created resources without repeating myself! Please, what is
the "Rails way" of doing this thing?
On the ideal world, I put filters in my resources, limiting the admin
operations to the admin users, and the /admin namespace somewhat maps/
points to those resources instead... Please help me clarifying my
mind :-)
Cheers,
Rúben
Answer to the second question inlined below:
You may check the following articles:
http://www.fallenrogue.com/articles/178-Creating-a-RESTful-admin-section-in-Rails
http://www.fallenrogue.com/articles/181-Creating-a-RESTful-admin-section-in-Rails-with-2-controllers
I have not yet tried them myself bu they seem to be reasonable. It
would be great it you can try and provide feedback here again.
> Cheers,
> Rúben
HTH,
--
Ersin Er
>
> look here:
> http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-
> first-full-tutorial-part-2
>
> you will get a lot of answers.
>
> the tutorial starts here:
> http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-
> first-full-tutorial
>
indeed I found! excelent tutorials! thank you!
however, my fears became real.. what Akita really do is mannually
copy the resource generated files inside the admin namespace,
efectivly repeating code... goodbye DRI, now I have *two* pieces of
code to mantain :-(
anyway, I learned a lot about rails 2 with those two posts! thank you!
Rúben
Also: http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/6b15ff7beb729cf1
> > Cheers,
> > Rúben
>
> HTH,
>
> --
> Ersin Er
>
--
Ersin Er
http://www.fallenrogue.com/articles/178-Creating-a-RESTful-admin-section-in-Rails
This is typically how I have seen it done using a single controller and
views with conditional displays of admin stuff or with routing to admin
views if logged in, etc.
Ruben Fonseca wrote:
> On 2007/12/27, at 10:43, Bruno Reis wrote:
>
>>
> indeed I found! excelent tutorials! thank you!
>
> however, my fears became real.. what Akita really do is mannually
> copy the resource generated files inside the admin namespace,
> efectivly repeating code... goodbye DRI, now I have *two* pieces of
> code to mantain :-(
>
> anyway, I learned a lot about rails 2 with those two posts! thank you!
>
> R�ben
--
Posted via http://www.ruby-forum.com/.
Mobile: +55 53 9129.4593
MSN: mas...@gmail.com
UIN: 343716195
Jabber: everton...@jabber.org
"If art interprets our dreams, the computer executes them in the guise of programs!" - Alan J. Perlis
Anyway, the reason for the post is, that I was reading the Rails Guides
(rake doc:guides), and there is this interesting one about routing =>
"Rails routing from the outside in" which explains a whole lot of stuff.
And I came up with this solution (but didn't test it yet) for the unused
actions on the public controllers and views.
map.with_options(:only => [:index, :show]) do |public|
public.resources :products, :users
end
map.namespace(:admin) do |admin|
admin.resources :products, :users
end
I think this can solve the issue, by using 2 controllers.
What are the articles you're referring to in the above? I'm on the
mailing list and don't see the links you mentioned.
--
Darryl L. Pierce <mcpi...@gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
It's easier to see the whole discussion with this link:
http://www.ruby-forum.com/topic/136715#769291