I think `:code` is disconnected because it is just using `hidden_field_tag` instead of `f.hidden_field_tag` (to get the parameter into the lev world of handlers/paramify you need to use the form object provided by the `lev_form_for` block.  Here's an example with hidden fields from Exercises:


    <%= lev_form_for :register, url: users_register_path, method: :put do |f| %>
      <div class="checkbox">
        <label>
          <%= f.check_box :i_agree %> I have read the terms listed above and I agree to be bound by their terms
        </label>
      </div>
    
      <%= f.hidden_field :contract_1_id, value: contracts[0].id %>
      <%= f.hidden_field :contract_2_id, value: contracts[1].id %>
      <%= f.submit "Register", id: "register_submit" %>
    <% end %>

Hmm. I've never reused the same action before for both a GET and a POST, so I didn't anticipate that need.  So maybe just do what you were doing, but if you have a sec it'd be cool to document this as an issue for Lev so we can get around to it at some point.

JP


On Feb 28, 2014, at 3:37 AM, Karen Chan <notifications@github.com> wrote:

> In app/handlers/reset_password.rb:
> 
> > +  include Lev::Handler
> > +
> > +  uses_routine ResetPassword
> > +
> > +protected
> > +
> > +  def authorized?
> > +    true
> > +  end
> > +
> > +  def handle
> > +    identity = Identity.where(reset_code: params[:code]).first
> > +    fatal_error(code: 'Reset password link is invalid', offending_inputs: [:code]) if identity.nil? or params[:code].nil?
> > +    if request.post?
> > +      run(SetPassword, identity,
> > +          params[:reset_password].try(:[], :password),
> I tried out paramify and it wasn't able to do what I was doing by hand. This might be a problem with the structuring of my code...
> 
> code doesn't have a namespace. It's just params[:code]. paramify doesn't seem to be able to deal with this.
> password and password_confirmation are only required if code is valid and the request is post. I tried doing validates :password, presence: true, if: Proc.new {|a| request.post? } and validates :password, presence: true, if: :is_post? and they both failed because it does not use my ResetPassword instance as the context. It was not possible to get hold of the request or any methods I define in ResetPassword.
> May be I'm just using it wrong?
> 
> —
> Reply to this email directly or view it on GitHub.
>