Skip to content

Commit

Permalink
Display file name to process and skip if attr_accessible not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Oct 4, 2014
1 parent e971ed4 commit 896977e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/attr_accessible2strong_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ def self.convert(file_or_dir, no_rename = false)
end
@files.each do |filename|
c = AttrAccessible2StrongParams::Converter.new
c.read_attr_accessible(filename)
next if c.read_attr_accessible(filename).blank?
print filename, ' found:', c.@model_fields
c.remove_attr_accessible_from_model(filename, no_rename)
c.write_controller_with_strong_params(nil, no_rename)
puts
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/attr_accessible2strong_params/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def remove_attr_accessible_from_model(filename, no_rename = false)

def write_controller_with_strong_params(filename = nil, no_rename = false)
filename = "#{File.dirname @model_file_name}/../controllers/#{@model_class_name.pluralize.underscore}_controller.rb" if filename.nil?
return unless File.exist? filename
root_node, comments, buffer = parse_file_with_comments(filename)
sp_src_buffer = Parser::Source::Buffer.new('(string)')
sp_src_buffer.source = ModifyControllerRewriter.new(@model_class_name, @model_fields).rewrite(buffer,root_node)
Expand Down

0 comments on commit 896977e

Please sign in to comment.