Hobo / hobo

The web app builder for Rails (moved from tablatom/hobo)
http://hobocentral.net
103 stars 39 forks source link

Regression in creator action #149

Closed haslinger closed 9 years ago

haslinger commented 9 years ago

I'm quite sure, that there is a regression in the latest changes to the creator actions. I have the latest github version checked out:

class Conversation
...
  lifecycle do
    state :active, default: true
    create :initiate, become: :active, available_to: :all, new_key: true, params: [:name]
...
  end
...
  def create_permitted?
    true
  end

  def view_permitted?(field)
    customer_is?(acting_user)
  end

and suddenly in the creation method call get

Exception: #<Hobo::PermissionDeniedError: Hobo::PermissionDeniedError>
params:
{"page_path"=>"/conversations/initiate",
 "authenticity_token"=>"flP2yp17m8GBm+mMNtUCaa5Kpvgqb42S7e4wDojCi3A=",
 "conversation"=>
  {"customer_id"=>"1376",
   "name"=>"Bitten rufen Sie mich zurück, meine Telefonnummer ist:"},
 "action"=>"do_initiate",
 "controller"=>"conversations"}

whereas in Hobo 2.1.1 it's still working fine. I have to extend view permissions to

  def view_permitted?(field)
    customer_is?(acting_user) ||
    new_record?
  end

which is fine for me, but I assume, it will break some people's code...

stevemadere commented 9 years ago

This was caused by my PR #147

I mistakenly assumed that HoboModel#user_new was just like ActiveModel#new but with the addition of a call to set_creator() .

I now see that it also invokes user_view for some reason.

I will submit another PR to fix this.

haslinger commented 9 years ago

Cool, thank you, sounds right to me, I will check on sunday it that would fix it for my app...

haslinger commented 9 years ago

I just wanted to confirm, that it's fixed also for my app. Thank you, @stevemadere and @iox for fixing so fast!

iox commented 9 years ago

Nice! :+1: