The controller is simple

class UsersController < ApplicationController

  hobo_user_controller

  auto_actions :all


  def index
    hobo_index  do |wants|
            wants.xml   {
                    render :xml =>  @users.to_xml( :include =>
[:most_recent_status, :messages ])
                        }
      wants.html {   }
    end
  end

end

THAT'S USER'S MODEL

class User < ActiveRecord::Base

  hobo_user_model # Don't put anything above this

  fields do
    name          :string, :required
    email_address :email_address, :unique, :login => true
    administrator :boolean, :default => false
    status_id     :integer
    timestamps
  end

  has_many :messages, :dependent => :destroy
  has_many :statuses, :dependent => :destroy
  has_many :stories

  has_one :most_recent_status, :class_name => 'Status', :order =>
"created_at desc"

  # This gives admin rights to the first sign-up.
  # Just remove it if you don't want that
  before_create { |user| user.administrator = true if !Rails.env.test?
&& count == 0 }


  # --- Signup lifecycle --- #

  lifecycle do

    state :active, :default => true

    create :signup, :available_to => "Guest",
           :params =>
[:name, :email_address, :password, :password_confirmation],
           :become => :active

    transition :request_password_reset, { :active
=> :active }, :new_key => true do
      UserMailer.deliver_forgot_password(self, lifecycle.key)
    end

    transition :reset_password, { :active => :active }, :available_to
=> :key_holder,
               :params => [ :password, :password_confirmation ]

  end


  # --- Permissions --- #

  def create_permitted?
    true
  end

  def update_permitted?
    acting_user.administrator? ||
      (acting_user == self && only_changed?
(:email_address, :crypted_password,
                                            :current_password, :password, 
:password_confirmation))
    # Note: crypted_password has attr_protected so although it is
permitted to change, it cannot be changed
    # directly from a form submission.
  end

  def destroy_permitted?
    acting_user.administrator?
  end

  def view_permitted?(field)
    true
  end

end


ALSO I'VE TRIED ONE THING:  pasted code from statuses' model to story
model (except the model name itself) to see if there's any problem in
the structure. After migrating it appeared to seize working just like
status'. Maybe the problem is in multiple belongs_to (user and
message) ?

On Feb 24, 4:10 pm, Bryan Larsen <[email protected]> wrote:
> It doesn't look like a simple routing problem anymore, given that
> /users/1/stories works but users/1/statuses do not.  I suppose it could
> be a permission problem, but they usually manifest in a different manner.
>
> Could you post your users_controller code for me to take a look at?
>
> thanks,
> Bryan
>
> Edward Samokhvalov wrote:
> > Bryan, maybe it's some permission problem? LIke an app doesn't have
> > access to one controllers code and has to another or smth like that?
> > how can i check?

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en.

Reply via email to