Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionView::Template::Error (undefined method `email' for #<User:0x7f221f293ce8>): #236

Closed
itbakery opened this issue Mar 15, 2012 · 22 comments

Comments

@itbakery
Copy link

I run social_stream in Rails 3.2.2.
in social_stream-base-0.17.3/app/views/layouts/_header_signed_out.erb

ActionView::Template::Error (undefined method `email' for #User:0x7f221f293ce8):
9:


10:

11: <%= f.label :email %>
12: <%= f.email_field :email, :class => "input_username" %>
13:

14:

15: <%= f.label :password %>

Do any one have idea?

@atd
Copy link
Contributor

atd commented Mar 16, 2012

Everything suggest that your database have not those fields. Did you run the migrations?

@atd atd closed this as completed Mar 16, 2012
@itbakery
Copy link
Author

I see, but it work in Rails Console when try to test "User.email",
Any suggestiopn please?

@atd
Copy link
Contributor

atd commented Mar 18, 2012

Migrations are also needed in the rails console.

Try:

bundle exec rake social_stream:migrations:update
bundle exec rake db:migrate

@itbakery
Copy link
Author

I try already but error still remain. sir

Error:

NoMethodError in Frontpage#index

Showing /home/lookmee/.rvm/gems/ruby-1.8.7-p357@astvplus/gems/social_stream-base-0.17.3/app/views/layouts/_header_signed_out.erb where line #11 raised:

undefined method `email' for #User:0x7feb0c1b1440

Extracted source (around line #11):

8: <%= form_for User.new, :as => :user, :url => user_session_path do |f| -%>
9:


10:

11: <%= f.label :email %>
12: <%= f.email_field :email, :class => "input_username" %>
13:

14:

@atd
Copy link
Contributor

atd commented Mar 20, 2012

Could you run the following command and paste the output?

rails r "puts Actor.inspect"

@itbakery
Copy link
Author

$ rails r 'puts Actor.inspect'
Actor(id: integer, name: string, email: string, slug: string, subject_type: string, notify_by_email: boolean, created_at: datetime, updated_at: datetime, activity_object_id: integer, follower_count: integer)

@atd
Copy link
Contributor

atd commented Mar 20, 2012

Maybe you have your own User model in your application, overwriting social stream's one?

@itbakery
Copy link
Author

User model come from devise sir.
$ rails g devise user
before
$rails g social_stream:install

$ rails r "puts User.inspect"
User(id: integer, encrypted_password: string, password_salt: string, reset_password_token: string, reset_password_sent_at: datetime, remember_created_at: datetime, sign_in_count: integer, current_sign_in_at: datetime, last_sign_in_at: datetime, current_sign_in_ip: string, last_sign_in_ip: string, authentication_token: string, created_at: datetime, updated_at: datetime, actor_id: integer, language: string, connected: boolean, status: string, chat_enabled: boolean)

@atd
Copy link
Contributor

atd commented Mar 21, 2012

Social Stream defines user and conflicts with devise's user generator.

You must not run "rails g devise user" before "rails g social_stream:install"

@itbakery
Copy link
Author

I create new rails (3.2.2) only gem social_stream and run rails g social_stream:install. I got Multiple migration. How to fix it?

/home/lookmee/.rvm/gems/ruby-1.8.7-p357@astvplus/gems/activerecord-3.2.2/lib/active_record/migration.rb:620:in `migrations': Multiple migrations have the version number 20120321133028 (ActiveRecord::DuplicateMigrationVersionError)

@itbakery
Copy link
Author

  create      db/migrate/20120321133027_create_mailboxer.rb
  create      db/migrate/20120321133028_add_notified_object.rb
  create      db/migrate/20120321133029_add_notification_code.rb
  create      db/migrate/20120321133030_add_attachments.rb

how to prevent to generate multiple migrations
Thank for greate support.

@atd
Copy link
Contributor

atd commented Mar 21, 2012

Which is the other migration with version number 20120321133028?

Could you post the output of ls db/migrate/20120321133028*

@itbakery
Copy link
Author

$ cat 20120321133028_add_notified_object.rb
class AddNotifiedObject < ActiveRecord::Migration
def self.up
change_table :notifications do |t|
t.references :notified_object, :polymorphic => true
t.remove :object_id
t.remove :object_type
end
end

def self.down
change_table :notifications do |t|
t.remove :notified_object_id
t.remove :notified_object_type
t.references :object, :polymorphic => true
end
end
end

@atd
Copy link
Contributor

atd commented Mar 21, 2012

ls please

@itbakery
Copy link
Author

$ ls
20120321133027_create_mailboxer.rb
20120321133028_acts_as_taggable_on_migration.rb
20120321133028_add_notified_object.rb
20120321133029_add_notification_code.rb
20120321133030_add_attachments.rb

@itbakery
Copy link
Author

$ ls db/migrate/20120321133028*
db/migrate/20120321133028_acts_as_taggable_on_migration.rb
db/migrate/20120321133028_add_notified_object.rb

@atd
Copy link
Contributor

atd commented Mar 21, 2012

Ok, this is a mailboxer issue. See: mailboxer/mailboxer#35

@itbakery
Copy link
Author

Thank you. what is the stable way to run "rails g"?

@itbakery
Copy link
Author

i run rails destroy social:install. and i found conflict on 20120321133028*.

  invoke  social_stream:base
  invoke    acts_as_taggable_on
  remove      db/migrate/20120321133028_acts_as_taggable_on_migration.rb
  invoke    devise
  remove      config/initializers/devise.rb
  remove      config/locales/devise.en.yml
  invoke    mailboxer
  remove      config/initializers/mailboxer.rb
  remove      db/migrate/20120321133027_create_mailboxer.rb
  remove      db/migrate/20120321133028_add_notified_object.rb
  remove      db/migrate/20120321133029_add_notification_code.rb
  remove      db/migrate/20120321133030_add_attachments.rb

@atd
Copy link
Contributor

atd commented Mar 21, 2012

What do you mean by "stable"?

@itbakery
Copy link
Author

Sorry. I mean step-by-step of rails g and can i skip social_stream:install?

SocialStream:
social_stream:base:install
social_stream:documents:install
social_stream:events:install

social_stream:linkser:install
social_stream:presence:install

@atd
Copy link
Contributor

atd commented Mar 22, 2012

This is fixed in maiboxer 0.6.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants