I'm new to rails, my command:
bin/rails generate model database Date:date Endpoint:text User:string
Domain:string
into the command line which then generated:
invoke active_record
create db/migrate/20150805174248_create_databases.rb
create app/models/database.rb
invoke test_unit
create test/models/database_test.rb
create test/fixtures/databases.yml
and after I ran:
bin/rake db:migrate
However, when following this tutorial http://guides.rubyonrails.org/getting_started.html SECTION(5.3)
When trying to save data to the controller/database it tells me to access app/controllers/articles_controller.rb (articles being the variable name they used).
The problem I face is that databases_controller.rb was never created in the first place! Can anyone provide any insight? thanks!
NEW QUESTION The file databases_controller.rb is empty. I have created one before a few weeks ago and it was full with def index,new, edit, C,R,U,D. However this one is empty. As I'm supposed to add
def create
@article = Article.new(params[:article])
@article.save
redirect_to @article
end
to the create portion
As a newcomer to Rails, Scaffolding
might be another handy option. Scaffolding
can be used to generate some of the major parts of a Rails application such as models, views and controllers for a new resource.
rails generate scaffold Database date:date endpoint:text domain:string
That way, you don't have to worry about creating the models, views and controllers separately for your newly added resource.
您需要生成控制器:
rails generate controller databases
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.