Adding data from rails seed DB file

Guys now i want to add just data in my users Table just for test with it
so I’m trying from use this code

users.create(:name => “admin”,:user => “admin”,:pass=> “123”)

in the seed file then when it trying to run rake db:seed

it always gave me the error [undefined local variable or method ‘users’
for main : object]

my table structure was
create_table :users do |t|
t.string :name
t.string :user
t.string :pass
t.timestamps

so i want to know what is the best way to add data to the DB
using the seed file

On 2 February 2014 16:01, Astm A. [email protected] wrote:

Guys now i want to add just data in my users Table just for test with it
so I’m trying from use this code

users.create(:name => “admin”,:user => “admin”,:pass=> “123”)

Try User.create it is a class method of the model.

Colin

when i used the command
User.create(:name => “admin”,:user => “admin”,:pass=> “123”)
it gives me the same error
but then i used the command
Users.create(:name => “admin”,:user => “admin”,:pass=> “123”)
it not gave me any error
now when i tried to use the command Rails c then Users.All
to show the data from the command screen
it gave me the error ( unintialized constant Ur)

On 2 February 2014 17:04, Astm A. [email protected] wrote:

when i used the command
User.create(:name => “admin”,:user => “admin”,:pass=> “123”)
it gives me the same error
but then i used the command
Users.create(:name => “admin”,:user => “admin”,:pass=> “123”)
it not gave me any error

What is the model name in user.rb? It should be User not Users.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs