I'm currently working on a Ruby on Rails application using RubyMine 5.4.3.2.1. I'm using Rails 4 and Ruby 1.9.3p429. In my application, I have a class file 'user.rb' with the following code:
class User < ActiveRecord::Base
validates :first_name, presence: true
validates :last_name, presence: true
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness:{case_sensitive: false }
validates :password, length: { minimum: 6}
has_secure_password
before_save { self.email = email.downcase }
end
and a related migration file '[timestamp]_create_users.rb' with the following:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :first_name
t.string :last_name
t.string :email
t.string :password_digest
t.timestamps
end
end
end
Using the RubyMines Run Rake Task, I ran a db:migration to create the users table. The problem is that RubyMines doesn't accept any User.create command to enter data into the database. E.g
User.create (first_name:"John",last_name:"Doe",email:"[email protected]",password:"testing",password_confirmation:"testing")
The error it gives is
SyntaxError: (irb):1: syntax error, unexpected tLABEL
User.create (first_name:"John",last_name:"Doe",ema...
^
(irb):1: syntax error, unexpected ',', expecting $end
...er.create (first_name:"John",last_name:"Doe",email:"jdoe@...
^
This works fine when I run it in my command prompt using the 'rails console', but it gets tedious to repeatedly refer to the command prompt. I've tried running the Rails Console in RubyMine in both default and development, with neither yielding a positive result. Can anyone tell me what I'm doing wrong and how to resolve this?
remove the space between User.create and the left parenthesis User.create(...) instead of User.create (...)
Cheers