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

Padrino helpers vs generators model singular_name #1275

Closed
j15e opened this Issue May 3, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@j15e
Contributor

j15e commented May 3, 2013

The scaffolded expected post params dosen't include the class namespace .underscore.gsub(/^.*\//, '') whereas the form builder include the class namespaces .class.to_s.underscore.gsub(/\//, '_').

Generator

https://github.com/padrino/padrino-framework/blob/master/padrino-admin/lib/padrino-admin/generators/templates/page/controller.rb.tt#L15

post :create do
  @<%= @orm.name_singular %> = <%= @orm.build("params[:#{@orm.name_singular}]") %>

https://github.com/padrino/padrino-framework/blob/master/padrino-admin/lib/padrino-admin/generators/orm.rb#L20

  @name_singular  = name.underscore.gsub(/^.*\//, '') # convert submodules i.e. FooBar::Jank.all # => jank

Form helpers

# https://github.com/padrino/padrino-framework/blob/master/padrino-helpers/lib/padrino-helpers/form_builder/abstract_form_builder.rb#L248
# Returns the object's models name
#   => user_assignment
def object_model_name(explicit_object=object)
  explicit_object.is_a?(Symbol) ? explicit_object : explicit_object.class.to_s.underscore.gsub(/\//, '_')
end

cc @dariocravero

@ghost ghost assigned dariocravero Jul 1, 2013

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Jul 1, 2013

Member

Not really sure if I understood, @dariocravero can u crack down this ? Thanks!

Member

DAddYE commented Jul 1, 2013

Not really sure if I understood, @dariocravero can u crack down this ? Thanks!

@j15e

This comment has been minimized.

Show comment
Hide comment
@j15e

j15e Jul 1, 2013

Contributor

Edit : I meant the scaffolded parameters in controllers doesn't match form helper params for the model name. One is stripping the modules/namespaces whereas the other is not.

Contributor

j15e commented Jul 1, 2013

Edit : I meant the scaffolded parameters in controllers doesn't match form helper params for the model name. One is stripping the modules/namespaces whereas the other is not.

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Jul 2, 2013

Member

Okay, makes sense, @dariocravero do you have time for this?

Member

DAddYE commented Jul 2, 2013

Okay, makes sense, @dariocravero do you have time for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment