1 - "" & '' express
Generally,we use "" in development,and in most time,'' is same to "",but '' is also has its speciality,and the most difference between "" & '' is that '' can not support "#{}",but '''s value is the true value. app
for example,"\n" is another new line,but '\n' means "\n",but it will be changed to "\\n",because console's output all use "" ide
2 - named routes this
We often used the routes like this: match '/about', to: 'welcome#about',I often get an error that I forgot to write the "," between '/about' and "to",so write it like this also correct: spa
match '/about' => 'welcome#about' orm
3 - user parse as the "database" ci
Parse provide active::record like APIs,but it is not active::record.when you write test for model,for example,user model,you can not do like this: get
before { @user = User.new(:username => "blues@blues.com", password: "123456") } it
and you can to test the username's exist in model,if you do like this,you will failed: console
describe "when username is not present" do
before { @user.username = "" }
it { should_not be_valid }
end
So how to test it? If you do like this in console,you will find when you call "new" to get a new user,if you initialize its property at first,and then you assignment one value to the property "username",it will appear a strange thing like this:
#<User:0x007fae2eaca9e8 @unsaved_attributes={:username=>"test@test.com", :password=>"123456", "username"=>"p@p.com"}, @attributes={:username=>"test@test.com", :password=>"123456", "username"=>"p@p.com"}>
one object has two same fields,but the way expressing it is different.So you should do like this:
before do
@user = User.new
@user.username = "1@1.com"
end
then when you test a empty value for user model,you can do like this:
@user.username = ""
if you did not do validate,your test will failed,but it is normal,and if you do validate,your test will success,it is also correct.
Thanks,
Blues