0

meanwhile I'm pretty desperate since I can't continue working on my Website. I created a Ruby on Rails server and added a products controller via scaffolding. When I am on my local server, I can add a new product (new object of the product category) with the already given Rails structure. But I want to add the objects/products in my text documents, but where exactly is this possible?

I know I can add a product like so: bike1 = Bike.create ( :name => "Nice Bike" ) But where exactly do I have to add it that it is displayed on the show page of the Product controller?

And is it possible to see my created products in my database folder?

Thank You!

1 Answer 1

1

is it possible to see my created products in my database folder?

If you are using sqlite as your database - then you can see content with sqlite viewer applications. http://sqlitebrowser.org/ can be one

But I want to add the objects/products in my text documents

Do you mean you want to have a script that will populate your database?

Ruby on Rails has db/seed.rb file, it suppose to have starting content for your app. For example admin user account or default categories http://edgeguides.rubyonrails.org/active_record_migrations.html#migrations-and-seed-data

# db/seed.rb
Bike.create(name: "Nice Bike")

Also you can make rake task to create some records, or you can just run rails c and type ruby commands in command line, such as Bike.create(name: "Nice Bike")

To help you managing content of your app on early stage, you can check https://github.com/sferik/rails_admin, it generate nice UI base on relations that your define in your model. It's easy to start with it.

Also I would recommend you to use database server such as PostgreSQL or MySQL. With that you can connect directly to database server and see content. There is also applications with nice UI to manage content and structure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.