app/controllers/posts_controller.rb
## Generates a Post object from form submission content, or initializes a new one
Generates a Post object from form submission content, or initializes a new one
Generates a Post object from form submission content or initializes a new one
def post_from_form(params)
    post = Post.find_by(id: params[:id]) || Post.new
    unless post.id.nil?
      verify_can_modify_post(post)
    end
    date = params[:post][:date]
    time = params[:post][:time]
    post.datetime = DateTime.parse("#{date} #{time}")
    post.content = params[:post][:content]
    post.author = current_user
    post
  end
def post_from_form ( params ) post = Post . find_by ( id : params [ :id ] ) || Post . new unless post . id . nil? verify_can_modify_post ( post ) end date = params [ :post ] [ :date ] time = params [ :post ] [ :time ] post . datetime = DateTime . parse ( "#{date} #{time}" ) post . content = params [ :post ] [ :content ] post . author = current_user post end
Generates a Post object from form submission content, or initializes a new one
Generates a Post object from form submission content or initializes a new one
params
<not_specific>