Note that there are some explanatory texts on larger screens.

plurals
  1. POPony and Sequel associations conflict?
    primarykey
    data
    text
    <p>I've run into an issue when using Pony and Sequel in a Sinatra application. Without Pony everything goes just fine, but just requiring Pony sequel's associations break. Here's my models for a blog:</p> <pre><code>class Post &lt; Sequel::Model one_to_many :comments, :order =&gt; :date.asc(), :conditions =&gt; {:approved =&gt; 1} set_schema do primary_key :id varchar :title varchar :text varchar :category varchar :status datetime :date varchar :link end end class Comment &lt; Sequel::Model plugin :validation_helpers many_to_one :posts attr_accessor :ip, :user_agent, :referrer, :permalink set_schema do primary_key :id integer :post_id varchar :author varchar :comment DateTime :date varchar :email varchar :url varchar :approved end </code></pre> <p>Then I call them like this in a route</p> <pre><code>post '/:link' do @post = Post[:link=&gt;params[:link]] params[:comment].merge!( { :ip =&gt; request.ip.to_s, :user_agent =&gt; request.env['HTTP_USER_AGENT'].to_s, :referrer =&gt; request.env['REFERER'].to_s, :permalink =&gt; request.env['REFERER'].to_s } ) begin @comment = Comment.create params[:comment] @post.add_comment @comment rescue @message = $! end @title = @post.title haml :posts end </code></pre> <p>I don't even have to call pony somewhere, just requiring it <code>@post.add_comment @comment</code> fails. It says</p> <pre><code>NoMethodError - undefined method `_add_comments' for #&lt;Post:0x102b09890&gt;: /Library/Ruby/Gems/1.8/gems/sequel-3.21.0/lib/sequel/model/associations.rb:1078:in `send' /Library/Ruby/Gems/1.8/gems/sequel-3.21.0/lib/sequel/model/associations.rb:1078:in `add_associated_object' /Library/Ruby/Gems/1.8/gems/sequel-3.21.0/lib/sequel/model/associations.rb:743:in `add_comment' </code></pre> <p>Seems to me like a conflict with send? I don't even know how to start to debug it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload