ruby/rails string to class

params[:resource] = 'user'

params[:resource] = "users".singularize   

params[:resource].classify.constantize.

eval(params[:resource].classify)

Object.const_get(params[:resource].classify)


"user".pluralize => 'users'

你可能感兴趣的:(String)