Skip to content
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 · Fixed by #1345
Closed

Padrino helpers vs generators model singular_name #1275

j15e opened this issue May 3, 2013 · 3 comments · Fixed by #1345
Assignees
Labels
Milestone

Comments

@j15e
Copy link
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
Copy link
Member

DAddYE commented Jul 1, 2013

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

@j15e
Copy link
Contributor Author

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
Copy link
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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants