rails-erb-lint
Installations:
$ gem install rails-erb-lint
Usage:
$cd your-rails-app/app/views
$rails-erb-lint check
It will check syntax of all .html.erb files and displays all invalid files....
Customize rails-erb-lint to display line numbers of syntax error for invalid files...
$gem which rails-erb-lint
#It will display path of rails-erb-lint gem
/home/saritha/.rvm/gems/ruby-2.1.1/gems/rails-erb-lint-1.0.8/lib/rails-erb-lint.rb
then, Open rails-erb-lint.rb in editor...
replace your module with below code......
rails-erb-lint.rb
module RailsErbCheck
def self.valid_syntax?(erb)
begin
ActionView::Template::Handlers::Erubis.new(erb).result
rescue SyntaxError => error
puts "Error Occured In Line:#{error.inspect.split('syntax error')[0]}"
return false
rescue Exception
return true
end
end
end
Now check your views...
$rails-erb-lint check
# Displays invalid files and line numbers as shown below:
Error Occured In Line:#<SyntaxError: (erubis:27:
/home/saritha/ror/movierainbow/app/views/social/profiles/addfriends.html.erb => invalid
Error Occured In Line:#<SyntaxError: (erubis:9:
/home/saritha/ror/movierainbow/app/views/social/profiles/friends.html.erb => invalid
"95 files, 2 invalid files"
saritha@sartitha-pc:~/ror/movierainbow/app/views$ rails-erb-lint check
Checking for files in current directory: /home/saritha/ror/movierainbow/app/views
"95 files, 0 invalid files"
Thank You.................Happy Rails Coding...........:-)
Your blog is in a convincing manner, thanks for sharing such an information with lots of your effort and time
ReplyDeleteruby on rails training
ruby on rails training India
ruby on rails training Hyderabad