Skip to main content
added 297 characters in body
Source Link
snowYetis
  • 1.6k
  • 19
  • 28

My code works when I run the action like this,

def interest
    @interest = Interest.new
    @interest.user_id = current_user.id
    @interest.idea_id = @idea.id
    @interest.save
    @ideas = Idea.take(10)
    flash[:notice] = "A message has been sent to the poster."
    render "ideas/forum"
end

But,why do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
    belongs_to :user
    :title
    :category
    :content
    :user_id
    :createdDate
    :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
    has_many :ideas
    has_many :interests
end

Here is the button_to tag

<%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

And my route,

resources :ideas do
    resources :interests
end

Interest Model class Interest < ActiveRecord::Base belongs_to :user belongs_to :idea

has_many :users

:idea_id :user_id

end

NoMethodError - undefined method `interest' for #<Idea::ActiveRecord_Associations_CollectionProxy:0x007f9e5189bab0>:

activerecord (4.2.0)

My code works when I run the action like this,

def interest
    @interest = Interest.new
    @interest.user_id = current_user.id
    @interest.idea_id = @idea.id
    @interest.save
    @ideas = Idea.take(10)
    flash[:notice] = "A message has been sent to the poster."
    render "ideas/forum"
end

But,why do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
    belongs_to :user
    :title
    :category
    :content
    :user_id
    :createdDate
    :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
    has_many :ideas
    has_many :interests
end

Here is the button_to tag

<%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

And my route,

resources :ideas do
    resources :interests
end

My code works when I run the action like this,

def interest
    @interest = Interest.new
    @interest.user_id = current_user.id
    @interest.idea_id = @idea.id
    @interest.save
    @ideas = Idea.take(10)
    flash[:notice] = "A message has been sent to the poster."
    render "ideas/forum"
end

But,why do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
    belongs_to :user
    :title
    :category
    :content
    :user_id
    :createdDate
    :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
    has_many :ideas
    has_many :interests
end

Here is the button_to tag

<%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

And my route,

resources :ideas do
    resources :interests
end

Interest Model class Interest < ActiveRecord::Base belongs_to :user belongs_to :idea

has_many :users

:idea_id :user_id

end

NoMethodError - undefined method `interest' for #<Idea::ActiveRecord_Associations_CollectionProxy:0x007f9e5189bab0>:

activerecord (4.2.0)

My code works when I run the action like this,

  def interest
    @interest = Interest.new
    @interest.user_id = current_user.id
    @interest.idea_id = @idea.id
    @interest.save
 
    @ideas = Idea.take(10)
 
    flash[:notice] = "A message has been sent to the poster."
    render "ideas/forum"

 
end

But, whywhy do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
    belongs_to :user
 
    :title
    :category
    :content
    :user_id
    :createdDate
    :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
    has_many :ideas
    has_many :interests
 ….. a bunch of other code that does not matterend

Here is the button_tobutton_to tag on the

          <%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

Interest Model

class Interest < ActiveRecord::Base
  belongs_to :user
  belongs_to :idea

  has_many :users
  has_many :ideas

  :idea_id
  :user_id

end

And my route,

resources :ideas do
resources :interests


end

Error when using Create. Fires on current_user.ideas.interest

NoMethodError - undefined method `interest' forresources #<Idea::ActiveRecord_Associations_CollectionProxy:0x007f9e4f896e18>:interests
  activerecord (4.2.0) end

My code works when I run the action like this,

  def interest
@interest = Interest.new
@interest.user_id = current_user.id
@interest.idea_id = @idea.id
@interest.save
 
@ideas = Idea.take(10)
 
flash[:notice] = "A message has been sent to the poster."
render "ideas/forum"

 
end

But, why do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
  belongs_to :user
 
  :title
  :category
  :content
  :user_id
  :createdDate
  :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
  has_many :ideas
  has_many :interests
 ….. a bunch of other code that does not matter

Here is the button_to tag on the

          <%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

Interest Model

class Interest < ActiveRecord::Base
  belongs_to :user
  belongs_to :idea

  has_many :users
  has_many :ideas

  :idea_id
  :user_id

end

And my route,

resources :ideas do
resources :interests


end

Error when using Create. Fires on current_user.ideas.interest

NoMethodError - undefined method `interest' for #<Idea::ActiveRecord_Associations_CollectionProxy:0x007f9e4f896e18>:
  activerecord (4.2.0) 

My code works when I run the action like this,

def interest
    @interest = Interest.new
    @interest.user_id = current_user.id
    @interest.idea_id = @idea.id
    @interest.save
    @ideas = Idea.take(10)
    flash[:notice] = "A message has been sent to the poster."
    render "ideas/forum"
end

But,why do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
    belongs_to :user
    :title
    :category
    :content
    :user_id
    :createdDate
    :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
    has_many :ideas
    has_many :interests
end

Here is the button_to tag

<%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

And my route,

resources :ideas do
    resources :interests
end
added 431 characters in body
Source Link
snowYetis
  • 1.6k
  • 19
  • 28

My code works when I run the action like this,

  def interest
@interest = Interest.new
@interest.user_id = current_user.id
@interest.idea_id = @idea.id
@interest.save

@ideas = Idea.take(10)

flash[:notice] = "A message has been sent to the poster."
render "ideas/forum"


end

But, why do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
  belongs_to :user

  :title
  :category
  :content
  :user_id
  :createdDate
  :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
  has_many :ideas
  has_many :interests
 ….. a bunch of other code that does not matter

Here is the button_to tag on the

          <%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

Interest Model

class Interest < ActiveRecord::Base
  belongs_to :user
  belongs_to :idea

  has_many :users
  has_many :ideas

  :idea_id
  :user_id

end

And my route,

resources :ideas do
resources :interests


end

Error when using Create. Fires on current_user.ideas.interest

NoMethodError - undefined method `interest' for #<Idea::ActiveRecord_Associations_CollectionProxy:0x007f9e4f896e18>:
  activerecord (4.2.0) 

My code works when I run the action like this,

  def interest
@interest = Interest.new
@interest.user_id = current_user.id
@interest.idea_id = @idea.id
@interest.save

@ideas = Idea.take(10)

flash[:notice] = "A message has been sent to the poster."
render "ideas/forum"


end

But, why do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
  belongs_to :user

  :title
  :category
  :content
  :user_id
  :createdDate
  :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
  has_many :ideas
  has_many :interests
 ….. a bunch of other code that does not matter

Here is the button_to tag on the

          <%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

And my route,

resources :ideas do
resources :interests


end

My code works when I run the action like this,

  def interest
@interest = Interest.new
@interest.user_id = current_user.id
@interest.idea_id = @idea.id
@interest.save

@ideas = Idea.take(10)

flash[:notice] = "A message has been sent to the poster."
render "ideas/forum"


end

But, why do I get an undefined method for 'interest' when I use this line in my Interest action?

@interest = current_user.ideas.interest.create(params[:interest])

Here's my Idea model

class Idea < ActiveRecord::Base
  belongs_to :user

  :title
  :category
  :content
  :user_id
  :createdDate
  :updatedDate

Here's my User model (Devise)

class User < ActiveRecord::Base
  has_many :ideas
  has_many :interests
 ….. a bunch of other code that does not matter

Here is the button_to tag on the

          <%= button_to "I'm Interested", ideas_interest_path(:id => idea.id, :idea_id => idea.id, :user_id => idea.user_id) ,class: 'btn btn-primary' %>

Interest Model

class Interest < ActiveRecord::Base
  belongs_to :user
  belongs_to :idea

  has_many :users
  has_many :ideas

  :idea_id
  :user_id

end

And my route,

resources :ideas do
resources :interests


end

Error when using Create. Fires on current_user.ideas.interest

NoMethodError - undefined method `interest' for #<Idea::ActiveRecord_Associations_CollectionProxy:0x007f9e4f896e18>:
  activerecord (4.2.0) 
Source Link
snowYetis
  • 1.6k
  • 19
  • 28
Loading