Displaying 3 results from an estimated 3 matches for "createbooks".
2011 Jun 11
1
Having a problem adding a foreign key
...= Book.new(params[:book])
if @books.save
render "home/index"
#redirect_to :controller=>"home" ,:action=>"index"
else
render :action => ''new''
end
end
CREATE TABLE/BOOK MIGRATION
class CreateBooks < ActiveRecord::Migration
def self.up
create_table :books do |t|
t.text :title
t.text :author
t.integer :user_id, :null => false
t.timestamps
end
add_foreign_key(:books, :users)
end
BOOK VIEW
<h1>Book#new</h1>
<%= form_for(:...
2010 May 28
3
Beginner Facing Problem with rake db:migrate
...beginner for this Rails from the past 2 days I am working hard
to fix the following error
C:\Murali Rubby\demo\library>rake db:migrate --trace
(in C:/Murali Rubby/demo/library)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== CreateBooks: migrating
====================================================
-- create_table(:books)
rake aborted!
An error has occurred, all later migrations canceled:
Mysql::Error: Table ''books'' already exists: CREATE TABLE `books` (`id`
int(11) D
EFAULT NULL auto_increment PRIMARY KEY, `cr...
2009 Dec 24
4
NoMethodError
Hi,
In a few words, can someone explain to me the NoMethodError. Googling
for answers will get you to something but a direct answer from experts
will give you something.
NoMethodError in Book#new
Showing app/views/book/new.html.erb where line #4 raised:
undefined method `title'' for #<Book id: nil, created_at: nil,
updated_at: nil>
Extracted source (around line #4):
1: