Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7826299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:20:17+00:00 2026-06-02T09:20:17+00:00

Getting this error in posts>show when I try to load up a form. The

  • 0

Getting this error in posts>show when I try to load up a form.

The form is for users to send messages to each other. Grateful for any feedback!

Thanks.

NoMethodError in Posts#show

Showing /Users/fkhalid2008/loand/app/views/posts/show.html.erb where line #1 raised:

undefined method `user' for #<Post:0x12e2ae930>
Extracted source (around line #1):

1: <%= form_remote_tag (:update => 'message', :url => {:controller => 'main', :action => 'send_message', :user_id => @post.user.id}) do %>
2: <br>
3: <br />
4: <br />

POSTS>SHOW VIEW

<%= form_remote_tag (:update => 'message', :url => {:controller => 'main', :action => 'send_message', :user_id => @post.user.id}) do %>
<br>
<br />
<br />
<div class="field">
Hello! My name is <%= f.text_field :subject %> and I'm contacting you in response to your ad. I'm interested in learning more so get in touch! Here's my contact details: <%= f.text_field :body %>.
</div>
<button type="submit" class="btn span6 large">Submit</button>
<% end %>

POSTS CONTROLLER

def new
@post = Post.new

respond_to do |format|
  format.html # new.html.erb
  format.json { render :json => @post }
end
end

def edit
@post = Post.find(params[:id])
end

def create
    @post = Post.new(params[:post])

    respond_to do |format|
        if verify_recaptcha && @post.save
            format.html { redirect_to :action=> "index"}
            format.json { render :json => @post, :status => :created, :location => @post }
        else
            format.html { render :action => "new" }
            format.json { render :json => @post.errors, :status => :unprocessable_entity }
        end
    end
end

MAIN CONTROLLER

class MainController < ApplicationController

def send_message
message = Message.new
message.subject = params[:subject]
message.body = params[:message]
message.sender = User.find session[:user]
message.recipient = User.find params[:user_id]
if message.save
  ContactMailer.deliver_message_email message.recipient.email, message.id, request.host
  return redirect_to "/posts"
else
  render :text => "Hmm. Something seems to be wrong...let me look into it"
end

CONTACT MAILER

class ContactMailer < ActionMailer::Base

def message_email (recipient, id, host)
recipients   [ recipient ]
subject      "Weddoo: You have received a new message"
from         "admin@weddoo.com"
bcc          ["admin@weddoo.com"]
content_type "text/html"
body         :message_id => id, :host => host
sent_on Time.now
end

end
end

ROUTES.RB

Mysalary::Application.routes.draw do

resources :users do
 resources :messages
   end

resources :profiles
resources :pages
resources :posts

get "pages/home"
get "pages/about"
get "pages/legal"
get "pages/feedback"

root :to => 'posts#new'

end

POST MODEL

class Post < ActiveRecord::Base
attr_accessible :title, :job, :location, :salary

validates :title, :job, :location, :salary, :presence => true 
validates :salary, :numericality => {:greater_than_or_equal_to => 1} 

default_scope :order => 'posts.created_at DESC'
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:20:19+00:00Added an answer on June 2, 2026 at 9:20 am

    The error is saying there is no method user on the Post model. It points you directly to the first line.

    <%= form_remote_tag (:update => 'message', :url => {:controller => 'main', :action => 'send_message', :user_id => @post.user.id}) do %>
    

    so I’d say

    @post.user.id is your problem statement, that model doesn’t have a method user but it’s hard to know for sure without seeing the Post model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this error when I try to submit my form (/POSTS/SHOW): RuntimeError in
Im getting this routing error No route matches {:controller=>posts, :action=>show} when i click on
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Getting this error when try to add an item to my repositories/context: Collection has
I am having trouble getting my form to load, not sure why this is
I keep getting this error when I try to build my project which uses
I am getting this error here is my code if(isset($_POST['submit'])) { $projTit=mysql_escape_string($_POST['projecttitle']); $projCat=mysql_escape_string($_POST['projectcategory']); $budget=intval(mysql_escape_string($_POST['budget']));
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
Keep getting this error after inserting a subdatasheet into a query and trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.