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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:26:09+00:00 2026-05-31T13:26:09+00:00

I have some rails app. For example I have next models: User , Post

  • 0

I have some rails app. For example I have next models: User, Post.
User model was generated Devise. Post model has columns text and user_id. Relationship: User has_many :posts and Post belongs_to :user. I need to determine who is owner of a post. For example owner can edit his posts.
If I understand correctly I need to create some helpers. I am new at rails and don’t understand who do this. Can someone help me?

  • 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-31T13:26:10+00:00Added an answer on May 31, 2026 at 1:26 pm

    The term “helper” can be confusing. If you use the rails generators, you’ll get a file in the app/helpers directory having the name <model>s_helper.rb. Here you can define methods that are directly accessible in your view templates. For example, you might define a method called pronoun based on the value stored in the gender field of your User model, like

    def pronoun(user)
      case user.gender
        when "M"
          "his"
        when "F"
          "her"
        else
          "their"
      end
    end
    

    so in the view referencing some user, you could do

    <%= @user.name %> got <%= pronoun(@user) %> ice cream in <%= @user.city %>.
    

    Of course you can do exactly the same thing in the model, and often that’s the better place to write helpers. For example, logic defining a user status might be

    def status_name
      if created_at > 30.days.ago
        "old timer"
      else
        "noob"
    end
    

    Then, wherever you can reference an instance of the user model, you can call @user.status_name

    Generally, model methods are less about presentation and more about logic.

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

Sidebar

Related Questions

I have a Rails app that will post some data to another Rails app.
I have a Rails app with some basic models. The website displays data retrieved
I have generated some scaffolding for my rails app. I am running the generated
I have some data that I want to store somewhere in my Rails app
I have already implemented some AJAX pagination in my Rails app by using the
I have a rails app with some nested data that I'd like to export
I have a MySQL/Rails app that needs search. Here's some info about the data:
I'm trying to override a Devise controller to have some minor changes, for example
I have a Rails app with the following action: def some_action headers['Access-Control-Allow-Origin'] = 'http://www.example.com'
OK, so I've built a Rails app in which I have some controller which

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.