Skip to content

Commit

Permalink
fixing bugs with names
Browse files Browse the repository at this point in the history
  • Loading branch information
nikone committed Feb 24, 2015
1 parent 26ce575 commit 22959d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def new
def create
post_params = params["post"]
@post = Post.new
@post.title = post_params["title"]
@post.body = post_params["body"]
@post.header = post_params["header"]
@post.content = post_params["content"]
@post.created_at = Time.now

PostMapper.new.save(@post)
Expand All @@ -23,8 +23,8 @@ def edit

def update
@post = PostMapper.find(params["id"])
@post.title = params["post"]["title"]
@post.body = params["post"]["body"]
@post.header = params["post"]["header"]
@post.content = params["post"]["content"]
PostMapper.new.save(@post)
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/post_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class PostMapper

def save(post)
if post.id
@@db.execute("UPDATE posts SET header = ?, content = ?, created_at = ? WHERE id = ?", [post.title, post.body, post.created_at, post.id])
@@db.execute("UPDATE posts SET header = ?, content = ?, created_at = ? WHERE id = ?", [post.header, post.content, post.created_at, post.id])
else
@@db.execute "INSERT INTO posts (header, content, created_at) VALUES (?,?,?)", [post.title, post.body, post.created_at.to_s]
@@db.execute "INSERT INTO posts (header, content, created_at) VALUES (?,?,?)", [post.header, post.content, post.created_at.to_s]
end
end

Expand Down
Binary file modified db/app.db
Binary file not shown.

0 comments on commit 22959d0

Please sign in to comment.