I have an advertiser model and an experiment model. I've setup the
associations as follows:
Advertiser has_many :experiments
Experiment belongs_to :advertisers
The experiments table has a column titled "experiment_type", which can
either be AOV or Conversion. I am trying to display experiments for the
particular advertiser by experiment_type.
I can successfully display ALL of the experiments by advertiser with the
following iteration
<% @advertiser.experiments.each do |experiments| %>
<td><%= experiments.id %></td>
<td><%= experiments.name %></td>
<% end %>
Or I can successfully display all the experiment_type with the following
iteration
<% @aov.each do |experiments| %>
<td><%= experiments.id %></td>
<td><%= experiments.name %></td>
<% end %>
What I cannot figure out is how to show the experiment_type by
advertiser. I thought something like
<% @advertiser.aov.each do |experiments| %> would work, but it gives me
an undefined method `aov' for #<Advertiser:
Any help would be appreciated. Thanks in advance.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/037862d98369619e74cbea00fd7517d1%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
test/fixtures/admin/...And that was causing rails tests to think my table was `admin_post_categories`. As soon as I moved the fixture files back to
test/fixtures/...All the tests just started working again.
On Thursday, June 30, 2016 at 8:12:20 AM UTC-3, Fernando Basso wrote:
I haveapp/controllers/admin/post_categories_controller .rb
app/models/post_category
app/test/controllers/admin/post_categories_controller_test .rb
When I runrake test app/test/controllers/admin/post_categories_controller .rb`I get errors like:1) Error:PostCategoryTest#test_should_not_save_post_category_ without_title: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "admin_post_categories" does not exist LINE 1: DELETE FROM "admin_post_categories"
Here's part of my `post_categories_controller_test.rb`: require 'test_helper'class Admin::PostCategoriesControllerTest < ActionController::TestCase setup do@post_category = post_categories(:one)endtest "should get index" doget :indexassert_response :successassert_not_nil assigns(:post_categories)endtest "should get new" doget :newassert_response :successend
So, basically my problem is that controllers, views and other things are namespaced (for now there is an "admin" namespace, but I will also add a "public" namespace later), but I want to use the same models (not namespaced models) for both the admin and the public area of this system.Thanks in advance for any help.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0a3ba954-0f15-4a12-9004-8658bad08e86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thank you very much! I am now reading about Active Record Validations
and it's making a lot more sense to me and your solution also makes
sense to me now. I am learning! I really appreciate your help.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/24ec8b9f05edd2a68be11e4e9f856b76%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.