Hi everybody, I have been following CommunityEngine and I think it's
awesome, so I was doing some tests with the forum section, and when a
response to a topic is given with some mail in the post (e.g.
[email protected]), I found this error:

NoMethodError in Sb postsController#create
undefined method `mail_to' for #<SbPost:0x338b514>
RAILS_ROOT: /Users/jcastaneyra/Projects/test
Application Trace | Framework Trace | Full Trace
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
attribute_methods.rb:260:in `method_missing'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
helpers/text_helper.rb:572:in `auto_link_email_addresses'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
helpers/text_helper.rb:565:in `gsub'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
helpers/text_helper.rb:565:in `auto_link_email_addresses'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
helpers/text_helper.rb:373:in `auto_link'
/Users/jcastaneyra/Projects/test/vendor/plugins/community_engine/
engine_plugins/white_list/init.rb:26:in `body_html_with_formatting'
/Users/jcastaneyra/Projects/test/vendor/plugins/community_engine/
engine_plugins/white_list/init.rb:22:in `format_content'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/callbacks.rb:178:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/callbacks.rb:178:in `evaluate_method'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/callbacks.rb:166:in `call'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/callbacks.rb:93:in `run'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/callbacks.rb:92:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/callbacks.rb:92:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/callbacks.rb:92:in `run'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/callbacks.rb:276:in `run_callbacks'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
callbacks.rb:344:in `callback'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
callbacks.rb:249:in `create_or_update'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
base.rb:2556:in `save_without_validation!'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
validations.rb:1019:in `save_without_dirty!'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
dirty.rb:87:in `save_without_transactions!'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
transactions.rb:200:in `save!'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
connection_adapters/abstract/database_statements.rb:136:in
`transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
transactions.rb:182:in `transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
transactions.rb:200:in `save!'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
transactions.rb:208:in `rollback_active_record_state!'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
transactions.rb:200:in `save!'
/Users/jcastaneyra/Projects/test/vendor/plugins/community_engine/app/
controllers/sb_posts_controller.rb:66:in `create'
/Users/jcastaneyra/Projects/test/vendor/plugins/community_engine/lib/
localized_application.rb:25:in `set_locale'
Request
Parameters:
{"topic_id"=>"1-como-le-hago-para-auto-report",
 "commit"=>"Guardar Respuesta",
 "authenticity_token"=>"GSjScsA5RoDeaZdprdStzb2CxDyfKbK3mdRx3DOsyUQ=",
 "post"=>{"body"=>"<p>Another test [email protected],
 to se what happen</p>"},
 "forum_id"=>"1-faq",
 "page"=>"1"}

Show session dump
Response
Headers:
{"Content-Type"=>"",
 "Cache-Control"=>"no-cache"}


So, I solved it in this way, changing init.rb in white_list plugin,
here is the code:

require 'white_list_helper'
ActionView::Base.send :include, WhiteListHelper
ActiveRecord::Base.send :include, WhiteListHelper

ActiveRecord::Base.class_eval do
  include ActionView::Helpers::TagHelper,
ActionView::Helpers::UrlHelper, ActionView::Helpers::TextHelper,
WhiteListHelper
  def self.format_attribute(attr_name)
    class << self; include ActionView::Helpers::TagHelper,
ActionView::Helpers::UrlHelper, ActionView::Helpers::TextHelper,
WhiteListHelper; end
    define_method(:body)       { read_attribute attr_name }
    define_method(:body_html)  { read_attribute "#{attr_name}_html" }
    define_method(:body_html=) { |value| write_attribute "#{attr_name}
_html", value }
    before_save :format_content
  end

  def dom_id
    [self.class.name.downcase.pluralize.dasherize, id] * '-'
  end

  protected
    def format_content
      body.strip! if body.respond_to?(:strip!)
      self.body_html = body.blank? ? '' : body_html_with_formatting
    end

    def body_html_with_formatting
      body_html = auto_link(body) { |text| truncate(text, :length =>
50) }
      # textilized = RedCloth.new(body_html, [ :hard_breaks ]) #not
using this
      # textilized.hard_breaks = true if textilized.respond_to?
("hard_breaks=")
      white_list(body_html)
    end
end


I am newbie with git, so I couldn't push this change to github, but
here is the solution if somebody need it, and maybe someone could push
it later. And also comments are welcome about this solution.

Regards.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/communityengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to