Question

I am getting the following error message on my localhost:3000/project/new

Could not find table 'projects'
Extracted source (around line #8):
@project = Project.new(params[:project]) --- line8

I am rendering a table from a partial in my projects folder

<h1>This is a form</h1>

<%= form_for(@project) do |f| %>
  <div class="field">
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </div>
  <div class="field">
    <%= f.label :description %><br />
    <%= f.text_field :description %>
  </div>
  <div class="field">
    <%= f.label :plan %><br />
    <%= f.text_field :plan %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

to the new file/action in the projects folder

<h1>Submit a new project here</h1>

<%= render 'form' %>

This is my Project Model

class Project < ActiveRecord::Base
  belongs_to :user
  validates :title, :uniqueness => true
end

This is my Routes

dsfasfd::Application.routes.draw do
  resources :project
  devise_for :users

root to: "home#index"

I ran rake:db migrate but its not doing anything, not creating a db and I can't find anything in the schema about projects either. Can't figure out what I'm doing wrong, why won't my rake create a table?

Was it helpful?

Solution

Firstly generate a migration file.

rails g migration products title:string description:string plan:string

and then migrate it

rake db:migrate

Follow this Guide.You really need this.

Update:

Seems like you have generated an empty migration file.Now have to do

1.Open that migration file and add these lines under the def

t.string :title

t.string :description

t.string :plan

2.Do rake db:migrate after that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top