Should I create controller actions if they won't have their own page(view)?(what are best practices?)

StackOverflow https://stackoverflow.com/questions/22588147

  •  19-06-2023
  •  | 
  •  

سؤال

I generated a controller:

rails generate controller Project title:string description:string plan:string

This creates the title, description & plan actions in my controller. However, I am now realizing that this may be overkill.

I want one project page that takes three input fields(title, description & plan). I don't want to have individual views for the three inputs but those are automatically created in my views folder. I could just leave those views blank but even as much as a newb as I am, I'm guessing this is not the way rails intends me to do this.

Is there a better way to do this?

هل كانت مفيدة؟

المحلول

Who downvoted? It's an honest question. I saw myself in your position a few months ago. I think you should read the Rails Guides and play some Rails4Zombies first because you are confusing two parts of Rails, the model and the controller.

Controller actions are like things that you can do with your app. In this case of a project, you can most probably create, read/browse (either one Project or all projects), update, or delete projects. These are associated with views, which you'll learn at some point. Title, description, and plan_action are put into Models, which are usually saved in your database. Again, I recommend reading the guides and watching Zombies first so you get some information on how Rails works.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top