Tag: 有条件的

如果URL包含字符串?

我如何使用条件来做一件事:name被传递给_form而另一件事如果:name没有传递? 用:name传递: Started GET “/inspirations/new?inspiration%5Bname%5D=Always+trust+yourself+more+than+you+doubt+yourself” for 127.0.0.1 at 2016-11-08 01:00:44 -0500 Processing by InspirationsController#new as HTML Parameters: {“inspiration”=>{“name”=>”Always trust yourself more than you doubt yourself”}} 没有:name传递: Started GET “/inspirations/new” for 127.0.0.1 at 2016-11-08 01:16:18 -0500 Processing by InspirationsController#new as */* User Load (0.3ms) SELECT “users”.* FROM “users” WHERE “users”.”id” = $1 LIMIT 1 [[“id”, 1]] […]

简单的Ruby’或’问题

在控制台中: @user.user_type = “hello” @user.user_type == “hello” true @user.user_type == (“hello” || “goodbye”) false 如何编写最后一个语句,以便检查@user.user_type是否包含在两个字符串之一中?