How to build a blog in rails 4
Why Stack Overflow recommends it
Stack Overflow users link it as the beginner tutorial they followed for building a Rails blog, usually when asking about errors or features like Devise users, comments and authorization that came up while following along.
Recommended by 1 people across 1 different months, 2014 to 2019.
What it is
A 71-minute screencast by Mackenzie Child, part of his 12 Web Apps in 12 Weeks series, that builds a simple Rails 4 blog with posts, comments and users. It uses the Devise gem for authentication and links to a GitHub repo with the finished code.
What people said
Recommends Richard Peck · 2014-01 · Stack Overflow · on “Gem for Creating a full featured Blog in Rails Application”
Here are some more resources you may benefit from: Tutorials How to build a blog in Rails 4 [this video] Rails Blog Tutorial [LINK] Simple Backend Area [LINK] Gems CanCan [LINK] (for admin athorization abilities) Slugalicious [LINK] (for slugged routes) Redactor [LINK] (for WYSIWYG) Paperclip [LINK] (for image upload) Blog If I were to create a simple blog app, I'd to this: Create Post , Category , Tag , Comment , Image models Use Slugalicious in the routes to route to the posts with routes like: domain.com/blog/your-post-title Add an admin area (probably with ActiveAdmin [LINK] || RailsAdmin [LINK] ), but you may wish to create your own with this tutorial [LINK] I'd use a WYSIWYG (such as Redact
Cites captain awesome · 2015-04 · Stack Overflow · on “Assigning Devise current_user to comment”
I was following following this online video ( here [this video] ) tutorial for a simple blog. Inside these blog posts are comments. In this tutorial the Devise gem was used and a migration was performed to assign add user_id to posts. I did a migration of add_user_id_to_comments similar to was done in the user_id migration for posts. class AddUserIdToComments < ActiveRecord::Migration def change add_column :comments, :user_id, :integer add_index :comments, :user_id end end My models contain the following: Comment model class Comment < ActiveRecord::Base belongs_to :post belongs_to :user end User model class User < ActiveRecord::Base has_many :posts has_many :comments # Include default devise modu
Cites mystreie · 2015-07 · Stack Overflow · on “rake aborted ! name error uninitialized constant Rails :: API :: Rdoc”
When i am trying to run rake db:migrate in my rails I get this error: rake aborted ! name error uninitialized constant Rails :: API :: Rdoc I am a newbie in the ruby on rails I was following the youtube tutorial to build a web blog application: [this video] but in the video it runs rake db just fine, i am so confused why I got rake aborted error in the command prompt, the migration file code is: class CreatePosts < ActiveRecord::Migration def change create_table :posts do |t| t.string :title t.text :body t.timestamps end end end would you please help me with this?
Cites Aniket Tiwari · 2016-02 · Stack Overflow · on “Rails authorization with cancan”
I am following this tutorial [this video] I am trying to authorize user only If user is admin he should be able to see all post and comments otherwise the normal user can see its own post only .I have read github page but was quite confusing [post_controller.rb] class PostsController < ApplicationController before_action :authenticate_user!, except: [:index, :show] def index @posts = Post.all.order('created_at DESC') end def new @post = Post.new end def show @post = Post.find(params[:id]) end def create @post = Post.new(post_params) @post.user = current_user if @post.save redirect_to @post else render 'new' end end def edit @post = Post.find(params[:id]) end def update @post = Post.find(params[:i
Cites Ignacio Palma Balboa · 2016-03 · Stack Overflow · on “How does blog comments works?”
I was watching rails tutorial by mckenzie [this video] and cannot understand how he makes the comments work for each post. _form partial looks like this: <%= form_for([@post, @post.comments.build]) do |f| %> <p> <%= f.label :name %> <%= f.text_field :name %> </p> <p> <%= f.label :description %> <%= f.text_area :description %> </p> <p> <%= f.submit %> </p> <% end %> So why does he has to call for this [@post, @post.comments.build] ?? Then he makes another partial for _comments that looks like this: <div> <h3><%= comment.name %></h3> <p><%= comment.description %></p> </div> So, how is he able to just call for "comment.name" without using the @ sign if there is no loop going on like @comment.each do
Cites Angel · 2017-03 · Stack Overflow · on “Encountered error "NoMethodError in Posts#show"”
I am new in ruby on rails in windows.. I am following some guide through youtube [this video] , but I encountered error Question: In part of <%= @post.item %> , what should I put in @post ?. Is it my method or the name of the field in my another view? "NoMethodError in Posts#show undefined method `item' for nil:NilClass Extracted source (around line #2): 1 2 <%= @post.item %> # the error indicates here 3 4 5 Submitted:<%= time_ago_in_words(@post.created_at) %> Ago 6 Controller class PostsController < ApplicationController def index end def addItem end def create @post = Post.new(post_params) @post.save redirect_to @post end private def post_params params.require(:post).permit(:item, :description)
Cites Angel · 2017-03 · Stack Overflow · on “Error encountered The action 'show' could not be found for PostsController”
I am new in ruby on rails in windows.. I am following some guide through youtube( [this video] ) but I encountered error "The action 'show' could not be found for PostsController" when I am defining the index method NOTE: The version of my ruby on rails in windows is latest. This is my first method I will do and to display my first view but it gives me an error. Question: Should I put the show method to my PostsController? Routes Rails.application.routes.draw do # For details on the DSL available within this file, see [LINK] resource :posts root "posts#index" end Posts Controller class PostsController < ApplicationController def index end end
Cites Freddee · 2019-06 · Stack Overflow · on “Adding Multiple Images or No Images to a Blog Post with Ruby on Rails”
I am making a website for K-pop fans to post whatever about K-pop. I am currently following a tutorial to build the website, however I would like for the user to have the option to upload no photos or one or more photos. How can I achieve this? (Here is the tutorial I am following [this video] ) I have tried searching up "Adding multiple photos or no photos using rails", however they only display "How to add photos to post" or etc. I am using repl.it to make the website.