another way

e-vive May 4, 2014

Perhaps a more efficient way:

def create
@post = Post.new(post_params)
if @post.save
  redirect_to @post, notice: "The post #{@post.title} was added to the system."
else
  render action: 'new'
end
end

where post_params is:

private

def post_params
  par...

Security

ksylvest May 4, 2014

In regards to @aamer's comment on including the password salt this is a bad idea. ActiveSupport::MessageVerifier is NOT encrypted so:

verifier = ActiveSupport::MessageVerifier.new('secret')
id = 'id'
salt = 'salt'
verifier.generate("#{id}-#{salt}") # "BAhJIgxpZC1zYWx0BjoGRVQ=-...