Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:22:33+00:00 2026-06-18T05:22:33+00:00

I’m going through Michael Hartl’s priceless tutorial and I got stuck with some Rspec

  • 0

I’m going through Michael Hartl’s priceless tutorial and I got stuck with some Rspec errors. I’ve double checked everything but it seems like I’m still missing something. Here’s what the error messages look like.

error

The thing that’s bothering me the most is when I was generating the Microposts model I accidentally made a typo in one of the options so I did rails destroy model Microposts to undo the generate command before generating the model again. I’m wondering if that has anything to do with the errors I’m seeing.

I really wish to finish this tutorial ASAP so I can get on with building my own web application. ANY help would be appreciated.

Here’s what my code looks like.

micropost_pages_spec.rb

require 'spec_helper'

describe "MicropostPages" do
    subject {page}
    let(:user) {FactoryGirl.create(:user)}
        before {sign_in user}
        describe "micropost creation" do
            before {visit root_path}

            describe "with invalid information" do
                it "should not create a micropost" do
                expect {click_button "Post"}.not_to change(Micropost, :count)               
            end

            describe "error messages" do
                before {click_button "Post"}
                it {should have_content('error')}
            end
        end
    end
end

microposts_controller.rb

class MicropostsController < ApplicationController
    before_filter :signed_in_user, only: [:create, :destroy]

    def create
        @micropost = current_user.micropost.build(params[:micropost])
        if @micropost.save
            flash[:success] = "Micropost created!"
            redirect_to root_path
        else
            render 'static_pages/home'
        end
    end

    def destroy
    end
end

static_pages_controller.rb

class StaticPagesController < ApplicationController
  def home
    @micropost = current_user.microposts.build if signed_in?
  end

  def help
  end

  def about
  end

  def contact
  end

end

user.rb (User model)

class User < ActiveRecord::Base
  attr_accessible :email, :name, :password, :password_confirmation
  has_secure_password
  has_many :microposts, dependent: :destroy

  before_save {self.email.downcase!}
  before_save :create_remember_token

  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :name,  presence: true, length: {maximum: 50}
  validates :email, presence: true, format: {with: VALID_EMAIL_REGEX},
                    uniqueness: {case_sensitive: false}
  validates :password, presence: true, length: {minimum: 6}
  validates :password_confirmation, presence: true

  private

    def create_remember_token
      self.remember_token = SecureRandom.urlsafe_base64
    end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:22:34+00:00Added an answer on June 18, 2026 at 5:22 am

    The error is with this line:

    @micropost = current_user.micropost.build(params[:micropost])
    

    It should be:

    @micropost = current_user.microposts.build(params[:micropost])
    

    You’re using micropost when you should be using microposts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
i got an object with contents of html markup in it, for example: string
I'm parsing an XML file, the creators of it stuck in a bunch social
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.