Rails Menus - ruby-on-rails

I would like to know if there is a good plugin for rendering navigation links in Rails. It would be nice if it could render links to all possible GET actions on a controller directly from the routes file.

Can I ask the purpose of your question? There are only four get actions in a RESTful controller, (index, show, edit, and new). The overhead in producing a list using a special route generator on the fly is probably too much.
You could simply create a partial that can render those four actions for whatever controller you're currently viewing (think params[:controller]).
As far as for all possible Get actions: All possible get actions would encompass the show action for each item in your database. That is, again, best handled in a partial and the use of link_to.
It's hard to give a complete answer though, because your circumstances seem unique.
I hope this helps even a little.
-Chris

While this does not answer ths specific question, you can see all of your OWN routes on the command line by running
rake routes
This will give you your own personal readout of all of your routes on the site, however like Chris said above, this isn't really a specific answer, more of an FYI.
Cheers!

You should try Mmmenu: http://github.com/snitko/mmmenu
It's very flexible.

Related

How can I set a text template on edit for Rails-Admin?

It's just a question.
Is it possible to set a text template on edit for Rails-Admin?
Whenever inputting some data, it takes a long time.
So, I think if I can call like a mail template, it would takes a short.
I searched that kind of the function for Rails-Admin but I couldn't find it..
Any ideas?
Rails admin does not have anything special that can help you with this. The edit view, the closest thing that could help you, is auto-generated from the model fields and associations. And unless you want to add a model for each template you probably should steer clear of this approach.
What you need is to build a custom action. You'd have to practically build everything like a regular controller.
Check out the actions page of the rails admin wiki for instructions on how to do this.
Good luck

Routing error rails "Couldn't find Fixture with id=list" when url = /fixtures/list

I currently have a fixture controller that was working fine,
However now it doesnt seem to work any more.
I have the following in the fixtures_controller
def list
#fixture = Fixture.all
Please see my github for the files https://github.com/jpknegtel/st_francis
If anyone could shed some light onto this it would be a great help
Update: Looking at your code, you do not at all have routes. You need routes for telling rails how to map the url from the request to the controllers and the actions within. Routes go in the config/routes.rb file.
Your problem is that you do not have a route for /fixtures/list. Rails thinks you want to show the fixture with the ID list. And does not find any record and throws an error.
You need to add some routes. I highly recommend to read the rails guide on routing. And I also recommend the use of ressourceful routing.
If you adopt the method names in your controllers this is really easy, otherwise you have to do a lot of work on your own. Read exspecially section 2. It took quite a while for me to understand RESTful routes, so do not give up - you will love them one day. If you have more questions, feel free to ask.

Technique for getting rid of the catch-all route in Rails

I just took over a Rails 3.0 project that is making use of the dreaded catchall route: match '/:controller(/:action(/:id))'. I'd like to get rid of it and replace it with proper defined routes. However, there are a large number of controllers and I want to make sure to do it without breaking anything, so I need to audit the project to see which controller actions are relying on the catch-all. Is there any tool or method to check all of the controllers to see which actions hit that particular routes.rb entry?
I had the exact same problem about a month ago. There is no easy answer that I know of, especially if it is a poorly tested application. The best method I found was:
Remove the black hole route.
Run rake routes and compare against each of my controllers.
Test everything I could find having to do with that controller and add in the missing routes where needed.
Repeat.
Best of luck to you.

Rails - What is right way to do a show page for a nested resource

since I am only going to be showing that one item, do I just have (example)
/the_thing/23
or do I still go with the /the_group/1/the_thing/23
I know I need to appropriately nest and have associations for forms and using nested routes for links, but for a show page is my link to it nested or not?
i.e. should I still show it within the context of its master or just on it's own. In this case the resource cannot be updated without the nesting i.e. on it's own.
Will a main intent be to show links back to the group?
This question is ONLY about the show page.
This is just a matter of choice, you can even create both routes depending on the context.
You should just ask yourself if it makes more sense for the user to see one url or the other: it's sheer user experience here.
It's true that it's only a matter of choice.
But consider a case, you have a Post model and Comment model, and Comment is a nested resource of Post. It does not make sense to have a separate route for show action of Comment, as showing comments without the relevant post makes no sense.
Hence, it's case specific as well.

Ruby on Rails simple website layout

I'm learning RoR, I've read some tutorials (railstutorial for the first one),
but I've a problem to define the logic layout of the my first simple website.
The structure is:
When you go to mysite.com you see a welcome page with the signup form or the link for login.
If you signup or you login into the site, you are at mysite.com/dashboard and you see a list of your messages.
You can go to mysite.com/$username and you see a page with a form where you can write a message for the $username.
Stop. That's it. It's very simple, I know, but is for learning.
The problem is this: I'm new to MVC paradigm and I don't know how structure the logic layout of my app. Of course there'll two models: User and Message. But for controllers? And which functions in any controllers? Should I use scaffolding?
Please give me a help, I'm very confused.
Thank you.
Controllers are the logic for the data, so to login/sign-up is really validating/creating a user, if you need to view the users dash board, well that's a look up on the user data so he goes there as well.
The messages, that will be a separate controller that can create/view messages!
As others have pointed out, your controllers contain the logic for your code and invoke views based on that logic by rendering or redirecting to pages. You can define whatever actions you want in your controllers, and then use routes to map a particular URL to a controller action. That being said, Rails gets a lot easier if you "go with the flow" and make some simple assumptions about the actions that could happen. Both your users and your messages represent rows in their respective database tables. There's no much you can do to a row in a database table - you can Create it, Read it, Update it, or Delete it (CRUD). If you define your actions in terms of these four logical actions, Rails lets you generate some easy routes.
You can back into any URL schema that you want, but what you are describing is:
Read the messages that are for a user on the dashboard
Create a message for a user when you go to another page (mysite/username)
Each of these maps to a CRUD action that you should be defining in your controllers.
Agreed also with other advice to simply do a few more tutorials that will probably clear this up.
If you haven't already, read Getting Started with Rails. Look out for the discussion on MVC and scaffolding. Playing around with scaffolding can help you learn where things go and is a great place to start for beginners.
Also, I highly recommend this book: Agile Web Development with Rails. It is very hands on and an easy read.

Resources