Skip to content

Commit

Permalink
Support attr_accessible appears multi times.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Oct 3, 2014
1 parent f06eadb commit a1e688b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/attr_accessible2strong_params/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
class AttrAccessible2StrongParams::Converter
def read_attr_accessible(filename)
root_node, comments = parse_file_with_comments(filename)
m = root_node.each_node(:send).select {|n| n.children[1] == :attr_accessible}.first
@model_class_name = m.parent.parent.children[0].children[1]
@aa_list = m.each_node(:sym).collect {|n| n.children[0]}
aa_nodes = root_node.each_node(:send).select {|n| n.children[1] == :attr_accessible}
aa_fields = []
aa_nodes.each do |m|
@model_class_name = m.parent.parent.children[0].children[1]
aa_fields <<= m.each_node(:sym).collect {|n| n.children[0]}
end
@model_fields = aa_fields.flatten
end

def write_controller_with_strong_params(filename)
Expand Down

0 comments on commit a1e688b

Please sign in to comment.