diff options
Diffstat (limited to 'src/controllers/posts_controller.rs')
-rw-r--r-- | src/controllers/posts_controller.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/controllers/posts_controller.rs b/src/controllers/posts_controller.rs index 99ff651..781f9f5 100644 --- a/src/controllers/posts_controller.rs +++ b/src/controllers/posts_controller.rs @@ -1,3 +1,4 @@ +#![cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] use comrak::{markdown_to_html, ComrakOptions}; use models::{NewPost, Post}; use rocket::{ @@ -28,7 +29,7 @@ fn new(_conn: DbConn) -> Page<NewPostTemplate> { #[post("/create", data = "<post>")] fn create(post: Form<NewPost>, conn: DbConn) -> Flash<Redirect> { - Post::create(post.get(), conn); + Post::create(post.get(), &conn); Flash::success(Redirect::to("/"), "Post successfully created!") } @@ -48,7 +49,7 @@ impl ShowPostTemplate { #[get("/<id>", format = "text/html")] fn show(id: i32, conn: DbConn) -> Page<ShowPostTemplate> { - let p = Post::get(id, conn); + let p = Post::get(id, &conn); Page { title: p.title.clone(), flash: None, @@ -66,7 +67,7 @@ implement_responder_for!(EditPostTemplate); #[get("/<id>/edit", format = "text/html")] fn edit(id: i32, conn: DbConn) -> Page<EditPostTemplate> { - let p = Post::get(id, conn); + let p = Post::get(id, &conn); Page { title: String::from("Edit post"), flash: None, @@ -76,13 +77,13 @@ fn edit(id: i32, conn: DbConn) -> Page<EditPostTemplate> { #[post("/update", data = "<post>")] fn update(post: Form<Post>, conn: DbConn) -> Flash<Redirect> { - Post::update(post.get(), conn); + Post::update(post.get(), &conn); Flash::success(Redirect::to("/"), "Post updated successfully!") } #[get("/<id>/delete", format = "text/html")] fn delete(id: i32, conn: DbConn) -> Flash<Redirect> { - Post::delete(id, conn); + Post::delete(id, &conn); Flash::success(Redirect::to("/"), "Post deleted!") } |