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 8446197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:51:54+00:00 2026-06-10T09:51:54+00:00

I am trying to build a friendship system sorta following this link: How to

  • 0

I am trying to build a friendship system sorta following this link: How to Implement a Friendship Model in Rails 3 for a Social Networking Application?. However the code seem to be very outdated, and I might of change it, what i am trying to do atm is simply to create a relationship, but this seem to not works.

So here my create

  #Send a friendship request
  def create
    Friendship.request(@customer, @friend)
    redirect_to friendships_path
  end

Which then technically would called the method request located in model which his already implemented in the previous post.

  def self.request(customer, friend)
    unless customer == friend or Friendship.exists?(customer, friend)
      transaction do
        create(:customer => customer, :friend => friend, :status => 'pending')
        create(:customer => friend, :friend => customer, :status => 'requested')
      end
    end
  end

and i also added these to the model

attr_accessible :status, :customer_id, :friend_id, :customer, :friend

However the friendship doesn’t get created. Any reason why not? I call the relationship has follow

<%= link_to "Add friend", friendships_path(:friend_id => customer), :method => :post %>
  • 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-10T09:51:56+00:00Added an answer on June 10, 2026 at 9:51 am

    You need to separate the @customer and @friend. In your link, you are setting :friend_id to the customer, and you are never setting the @customer id.

    Try this:

    def create
      @customer = current_account
      @friend = Account.find(params[:friend_id])
      Friendship.request(@customer, @friend)
      redirect
    end
    

    In the link_to you need:

    <%= link_to "Add Friend", friendships_path(:friend_id => friend),: method => :post %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to build openssl-fips-2.0 with NDK, before I was lucky found this link and
I was trying Build For Archiving application (from Titanium Mobile) with xCode 4.4, but
I'm trying build an App Engine connected Android application and am having some problems
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on
I am trying build a DataTable one row at a time using the following
Trying to build the following simple example #include <boost/python.hpp> using namespace boost::python; tuple head_and_tail(object
im trying to build a application or a method that goes through all of
Im trying to build sort of slide where when click on link .animate will
Trying to build a basic 3-layer architecture in my new application suite. For first
I'm trying build this network connection using BroadcastReceiver. When connection doesnt exist it will

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.