Skip to content

Instantly share code, notes, and snippets.

@thiagofm
Created October 12, 2010 10:39
Show Gist options
  • Save thiagofm/621993 to your computer and use it in GitHub Desktop.
Save thiagofm/621993 to your computer and use it in GitHub Desktop.
#CONTROLLER
def refresh
s=Source.find(:all)
@updated_feeds=Array.new
s.each do |source|
@rss = SimpleRSS.parse open(source.url)
#open rss if last modified date is older than the one saved in database and saves new rss data
if (source.last_mod==true && open(source.url).last_modified > source.updated_at.utc) || (source.build_date==true && @rss.channel.lastBuildDate.utc > source.updated_at.utc) || (source.build_date==false && source.last_mod==false )
Source.update (source.id, {:updated_at=>Time.now.utc})
@updated_feeds<< source.name
@rss.items.each do |item|
@m=Manga.new
if item.title =~ /^(([a-z]|[A-Z]|\s|\x2D|\x21|\x2B)*) (,?) \s (((Vol.|v)(\d*))\s)? ((Chapter\s|c|Ch.)(\d*))/x
title=$1.to_s
volume=$7.to_i
chapter=$10.to_i
@m.volume=volume
@m.chapter=chapter
@m.id_title=get_existence_of(title)
@m.parsed=true
else
@m.parsed=false
end
@m.full_title=item.title
@m.url=item.link
@m.id_source=source.id
@m.save
end
end
end
end
#ERROR
NoMethodError in FeedController#refresh
undefined method `name' for #<Manga:0x7f2647deaf48>
RAILS_ROOT: /home/thiagofm/Aptana Studio 3 Workspace/mangasort3
Application Trace | Framework Trace | Full Trace
vendor/rails/activerecord/lib/active_record/attribute_methods.rb:260:in `method_missing'
vendor/rails/activerecord/lib/active_record/validations.rb:398:in `send'
vendor/rails/activerecord/lib/active_record/validations.rb:398
vendor/rails/activerecord/lib/active_record/validations.rb:397:in `each'
vendor/rails/activerecord/lib/active_record/validations.rb:397
vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `call'
vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `evaluate_method'
vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in `call'
vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `each'
vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `send'
vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in `run_callbacks'
vendor/rails/activerecord/lib/active_record/validations.rb:1029:in `valid_without_callbacks?'
vendor/rails/activerecord/lib/active_record/callbacks.rb:286:in `valid?'
vendor/rails/activerecord/lib/active_record/validations.rb:1008:in `save_without_dirty'
vendor/rails/activerecord/lib/active_record/dirty.rb:79:in `save_without_transactions'
vendor/rails/activerecord/lib/active_record/transactions.rb:179:in `send'
vendor/rails/activerecord/lib/active_record/transactions.rb:179:in `with_transaction_returning_status'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:129:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:178:in `with_transaction_returning_status'
vendor/rails/activerecord/lib/active_record/transactions.rb:146:in `save'
vendor/rails/activerecord/lib/active_record/transactions.rb:158:in `rollback_active_record_state!'
vendor/rails/activerecord/lib/active_record/transactions.rb:146:in `save'
app/controllers/feed_controller.rb:84:in `refresh'
app/controllers/feed_controller.rb:65:in `each'
app/controllers/feed_controller.rb:65:in `refresh'
app/controllers/feed_controller.rb:53:in `each'
app/controllers/feed_controller.rb:53:in `refresh'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment