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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:15:10+00:00 2026-06-11T14:15:10+00:00

post.rb @allowed_post_types = [ ‘type1’, ‘type2’, ‘type3’, ‘type4’ ] #validate post type validates :post_type,

  • 0

post.rb

  @allowed_post_types = [
    'type1',
    'type2',
    'type3',
    'type4'
  ]

  #validate post type
  validates :post_type, :presence => true, :inclusion=> { :in => @allowed_post_types }, :if => :valid_post_type?



  def valid_post_type?
    self.post_type != 'type5'
  end

how can i enable validates :post_type line of code whenever the :post_type is not type5 ?

Tried the above but it doesn’t seem to work

  • 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-11T14:15:11+00:00Added an answer on June 11, 2026 at 2:15 pm

    Try:

    validates :post_type, 
              :presence => true, 
              :inclusion=> { :in => @allowed_post_types }, 
              :if => lambda { |a| a[:post_type] != "type5" }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

POST /api/crmteetimeapi.asmx/Login HTTP/1.1 Host: golffacility.com Content-Type: application/x-www-form-urlencoded Content-Length: length OwnerID=string&UserID=string&Password=string What language do I
I have a custom post type called song and i want to query the
Im develloping with symfony1.0,I'm using a file validation(validate/upload.yml) like that : methods: post: [logo_file]
Made a custom post type, Events, great. Now I want to get a second
javascript $('#send').on('click', function() { $.ajax({ 'url': $('#url').val(), 'type': 'post', 'complete': function (jqXHR, textStatus) {
Is this allowed? <form enctype=multipart/form-data action=__URL__ method=POST> <input type=text name=text_input /> <input type=other_types name=other_types_input
Here's a very quick example for my problem: http://img19.imageshack.us/img19/3575/workertool.png (I'm not allowed to post
As far as I understand Facebook allowes you (through the API) to post on
Post :belongs_to :user User :has_many :posts In my signup workflow they draft a Post
POST requests to server work fine until a file is attached. The form is

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.