On Mon, Aug 8, 2011 at 3:19 PM, Colin Law <[email protected]> wrote:
> On 8 August 2011 10:36, Sayuj Othayoth <[email protected]> wrote: > > Please don't top post, it makes it difficult to follow the thread. > Insert your reply at appropriate points in the previous message. > Thanks. > If you could manage to post in plain text rather than html it would > also make life more pleasant for some of us. > > > Hi Colin, > > > > It results: > > > > NoMethodError in Status_message#index > > > > Showing > > /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb > > where line #9 raised: > > > > undefined method `unscoped' for Users:Module > > Perhaps if you showed us the line causing the problem (and a few lines > around it) it might be easier to suggest a solution. > Also show the model class definitions for user and statusmessage. > Copy and paste the code, do not retype it. > > Also tell us anything unusual about your setup. Are you using an > authorisation gem for example? > > Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > Please see my code. I am using devise as authentication controller. MODELS: class User < ActiveRecord::Base #has_and_belongs_to_many :roles has_many :status_messages # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me # def role?(role) # return !!self.roles.find_by_name(role.to_s.camelize) # end end class StatusMessage < ActiveRecord::Base belongs_to :users #default_scope :order => "created_at DESC" end CONTROLLER: class StatusMessageController < ApplicationController def index @status = StatusMessage.all end def create @status = StatusMessage.new @status.user_id = current_user.id @status.status = params[:status] @status.save redirect_to :action => "index" end end ERB: <h1>Home</h1> <%= form_tag do |f| %> <%= text_area_tag :status %> <%= submit_tag "Submit" %> <% end %> <br /> *<% @status.each do |s| %> <%= s.users.email %> <%= s.status %> <br /> <% end %>* ERROR MSG: NoMethodError in Status_message#index Showing * /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb*where line *#9* raised: undefined method `unscoped' for Users:Module Extracted source (around line *#9*): 6: <% end %> 7: <br /> 8: <% @status.each do |s| %> 9: <%= s.users.email %> 10: <%= s.status %> <br /> 11: <% end %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

