Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Class Parameters #198

Merged
merged 11 commits into from Apr 10, 2013
Merged

Class Parameters #198

merged 11 commits into from Apr 10, 2013

Conversation

kbrezina
Copy link
Contributor

@kbrezina kbrezina commented Apr 5, 2013

Class parameter changes were tweaked to be in compliance with Rails 3.

@sodabrew
Copy link
Owner

sodabrew commented Apr 5, 2013

GitHub says that this cannot be automatically merged -- you might need to rebase up to current rails3 branch?

@kbrezina
Copy link
Contributor Author

kbrezina commented Apr 5, 2013

Hmm, I'll need to rebase again. There are a few more commits.
I'll do that on Monday.

def force_delete?
!params[:force_delete].nil? && params[:force_delete] == "true"
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it help to check for the Boolean true in addition to its String representation?
We could also DRY this a bit with

[:force_create, :force_update, :force_delete].each do |param|
  self.class.send(:define_method, (param.to_s+"?").to_sym) do
    !params[param].nil? && (params[param] == "true" || param[param] == true)
  end
end

I'm not sure if this detracts from readability though...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I simplified the conditions. The "!params[:force_xyz].nil?" was redundant.
  • if possible I'd keep the "def force_xyz? ... end" structure. IMHO, it's more readable than your version with 'self.class.send' and it's easier to find definition of such method. However, if you insist on it I can change it. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think the Boolean true should be checked in addition to its String representation? "params[:force_xyz]" should always contain a String.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update is much better.

@jeffweiss
Copy link
Contributor

I've just done a cursory examination of the content. I'll dive in today.

@jeffweiss
Copy link
Contributor

At first glance, it feels like we have a lot of duplication between NodeClassMembershipsController#update, NodeClassMembershipsController#destroy, NodeGroupClassMembershipsController#update, NodeGroupClassMembershipsController#destroy, NodeGroupsController#create, NodeGroupsController#update, NodeGroupsController#destroy, NodesController#create, NodesController#update, and NodesController#destroy.

I'm going to spend a bit digging in to determine if that's just perception or if we can maybe reduce duplication.

@jeffweiss
Copy link
Contributor

@fhrbek @kbrezina I opened a pull request fhrbek#1 against this one with a commit that reduces a great deal of the redundancy between the various controllers.

@jeffweiss
Copy link
Contributor

I will sometimes get this error when trying to delete a node from a group

ArgumentError (wrong number of arguments (2 for 1)):
  lib/has_many_through_dependent.rb:3:in `delete_records'
  lib/find_from_form.rb:29:in `block (2 levels) in assigns_related'
  app/controllers/node_groups_controller.rb:76:in `block in update'
  app/controllers/node_groups_controller.rb:73:in `update'


  Rendered /Users/jeff/.rvm/gems/ruby-1.9.3-p392@dear_lord_why/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
  Rendered /Users/jeff/.rvm/gems/ruby-1.9.3-p392@dear_lord_why/gems/actionpack-3.2.13/lib/action_dispatch/middleware/tem
...

This does not happen with the normal rails3 branch.

@fhrbek
Copy link
Contributor

fhrbek commented Apr 9, 2013

The problem with lib/has_many_through_dependent has been fixed in #207 and that's already merged in rails3. This PR should be rebased and the problem will be gone.

@jeffweiss
Copy link
Contributor

ah cool, ok.

@jeffweiss
Copy link
Contributor

Confirmed that merge does indeed fix the problem; however, now I seem to get

{"status":"ok","valid":"true","redirect_to":"http://localhost:3000/nodes/1"}

as the content returned when I edit a node...

@kbrezina
Copy link
Contributor Author

Jeff, I cannot reproduce the problem with the displayed json content.

Could you provide exact steps to reproduce it?
What browser are you using? It works fine on FF 19.0.2 & Chrome 26.0.1410.43 (Fedora17).

@jeffweiss
Copy link
Contributor

@kbrezina the problem started when I locally merged the PR into the rails3 branch. It didn't occur solely with this PR's branch. I was using Chrome, but I don't think that matters.
I'll try again first thing in the morning.

@jeffweiss
Copy link
Contributor

Turns out I had stale precompiled assets from before merging. Accurately detecting conflicts now. I'm gonna do one more once over on the code.

jeffweiss pushed a commit that referenced this pull request Apr 10, 2013
@jeffweiss jeffweiss merged commit 698d2b0 into sodabrew:rails3 Apr 10, 2013
@sodabrew
Copy link
Owner

Congrats!! May we close #142 and #182 now that this feature has landed?

@fhrbek
Copy link
Contributor

fhrbek commented Apr 11, 2013

Yes, #142 and #182 have become obsolete since all their features have already been merged into the target rails3 branch. It's time to clean up.

@ryanycoleman
Copy link

@fhrbek @kbrezina, I saw this demoed by @jeffweiss today. This is awesome! Thank you so much for getting this in.

jeffweiss pushed a commit to jeffweiss/puppet-dashboard that referenced this pull request Apr 17, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants