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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:12:34+00:00 2026-05-31T07:12:34+00:00

I have a relationship table with followed_id, follower_id, and status. I am using has

  • 0

I have a relationship table with followed_id, follower_id, and status. I am using “has many through” in my user model to create the association. A user has many following through and is following many through a reverse relationship. The status defaults to “requested” when a user follows another user.

So then a user has a list of their followers and each has a status of “requested”.

What I need in this list of followers is a link_to with a put method or a form that just finds that relationship and updates the status string to “approved”. It seems like it would be pretty easy but I have been searching for days and cannot figure it out. This is what I have so far:

In the users_controller this the action to change the status from “requested” to “approved”:

def activate
  @user = User.find(params[:id])
  params[:status] = {:status => 'approved'}
  @user.status = params[:user][:status]
  @user.save
  render 'show_followers'
end 

this is in the users_controller to list the followers:

def followers
 @title = "Followers"
 @user = User.find(params[:id])
 @users = @user.followers.paginate(:page => params[:page])
 render 'show_followers'
end

this is where I define status which is probably not right in user.rb model

def status
    Relationship.status.find_by_follower_id(self)
end

and this is the page where I show the followers:

      <% unless @users.empty? %>
        <% @users.each do |user| %>
        <tr>
            <td><%= image_tag user.avatar.url(:thumb) %></td>
            <td><%= user.full_name %></td>
            <td><%= user.company %></td>
            <td><%= user.approval.status %></td>
        <%end%>
            <td><%= form_for @user, url: activate_user_path(@user), :html => { :method => :put } do |f| %>
                <%= f.submit "approve" %>
                <% end %>
            </td>

        </tr>
        <%= will_paginate @users %>
        <% end %>

does anyone know how I can just update that string in Relationship table to “approved”?

  • 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-05-31T07:12:35+00:00Added an answer on May 31, 2026 at 7:12 am

    I see a potential problem in your form, think it should be for user and not @user & params[:user][:status] in activate method (params[:user][:status] should be nil as it has not been defined in your method). I’d rather have a remote link alongside all followers that are to be approved, then update the status using the link, but that bit is for later.

    So, the form :

    <%= form_for user, url: activate_user_path(user), :html => { :method => :put } do |f| %>
      <%= f.submit "approve" %>
    <% end %>
    

    and, assuming you’ve access to current user, and if not, passing current user too, i.e. @user via the form.

    def activate
      user = User.find(params[:id]) # user to be approved
      relationship = current_user.relationships.where(:follower_id => user).first # relationship record that has above user as follower and current user as followed
      relationship.update_attributes!(:status => 'approved')
      # redirect to users#followers passing current_user
    end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model and relationship: Table: Granddad GranddadID GranddadName Table: Father FatherID
I am using Entity Framework and I have two tables, a contact relationship table
i have a many to many table relationship that involves 2 logical tables. Record
Is it possible to have a relationship from a user table to a system
I have a table which has employee relationship defined within itself. i.e. EmpID Name
I have 2 table t1 -> t2 (common one to many relationship) with 140.000
I have two tables with a linking table describing their many-to-many relationship. TABLE buildings
I have a many-to-many relationship with a weight factor column in the bridge table
I have a table relationship that looks like the following: barn ------ PK barn_id
I have a many to many relationship table whith some datas in the jointing

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.