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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:27:09+00:00 2026-05-29T10:27:09+00:00

I tried to submit a new post and I get the error Title can’t

  • 0

I tried to submit a new post and I get the error

“Title can’t be blank”

So I removed the validations in my model and after trying again and posting something, the post is just blank, no data is saved whatsoever.

I don’t know what to do, I stuck on this one, help!

Update!

Here is the form

<% @post.tags.build %>
<%= form_for @post, :html => {:multipart => true } do |post_form| %>
 <% if @post.errors.any? %>
<div id="error_explanation">
  <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:      </h2>

  <ul>
  <% @post.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
  <% end %>
  </ul>
 </div>
 <% end %>


<div class="field">
<%= post_form.file_field :photo %>
</div>

  <div class="field">
   <%= post_form.label :title %><br />
   <%= post_form.text_field :title %>
 </div>
 <div class="field">
<%= post_form.label :url %><br />
<%= post_form.text_field :url %>
</div>
 <div class="field">
   <%= post_form.label :company %><br />
   <%= post_form.text_field :company %>
</div>
<div class="field">
  <%= post_form.label :language %><br />
  <%= post_form.text_field :language %>
</div>
 <div class="field">
  <%= post_form.label :framework %><br />
  <%= post_form.text_field :framework %>
 </div>
  <div class="field">
   <%= post_form.label :details %><br />
   <%= post_form.text_area :details %>
 </div>
 <h2>Tags</h2>
<%= render :partial => 'tags/form' ,
            :locals => {:form => post_form } %>
<div class="actions">
    <%= post_form.submit %>
    </div>
 <% end %>

here is the controller:

class PostsController < ApplicationController

  http_basic_authenticate_with :name => "franklinexpress", :password => "osxuser8", :except => [:index, :show, :new, :edit]

#def search
 #     @posts = Post.search(params[:search])
 #   end






# GET /posts
# GET /posts.json
 def index
   @posts = Post.search(params[:search])
   # @posts = Post.all
    # respond_to do |format|
     #format.html # index.html.erb
     #format.json { render json: @posts }
   #end
 end

 # GET /posts/1
 # GET /posts/1.json
 def show
   @post = Post.find(params[:id])

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

 # GET /posts/new
 # GET /posts/new.json
 def new
   @post = Post.new

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

   # GET /posts/1/edit
   def edit
   @post = Post.find(params[:id])
 end

  # POST /posts
  # POST /posts.json
  def create
    @post = Post.new(params[:post])

    respond_to do |format|
      if @post.save
        format.html { redirect_to @post, notice: 'Post was successfully created.' }
        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

  # PUT /posts/1
  # PUT /posts/1.json
 def update
   @post = Post.find(params[:id])

    respond_to do |format|
      if @post.update_attributes(params[:post])
       format.html { redirect_to @post, notice: 'Post was successfully updated.' }
      format.json { head :ok }
      else
        format.html { render action: "edit" }
       format.json { render json: @post.errors, status: :unprocessable_entity }
     end
   end
 end

   # DELETE /posts/1
   # DELETE /posts/1.json
  def destroy
    @post = Post.find(params[:id])
    @post.destroy

    respond_to do |format|
      format.html { redirect_to posts_url }
       format.json { head :ok }
    end
  end
end

in my model:

    class Post < ActiveRecord::Base
 validates :title, :presence => true
 validates :url, :presence => true
 validates :company, :presence => true
 validates :language, :presence => true
 validates_attachment_size :photo, :less_than => 4.megabytes
 validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png']

 has_many :comments, :dependent => :destroy
   has_many :tags

  attr_accessor :photo_file_name
  attr_accessor :photo_content_type
  attr_accessor :photo_file_size
  attr_accessor :photo_updated_at
  attr_accessible :photo

  accepts_nested_attributes_for :tags, :allow_destroy => :true,
   :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } }
   #paperclip-------------------------------
   has_attached_file :photo,
                 :url => "/assests/images/:id/:style/:basename.:extension",
                 :path =>   ":rails_root/public/assets/images/:id/:style/:basename.:extension"


   #:style => {:small => "150x200>"}

   def self.search(search)
    if search
     where('title LIKE ?', "%#{search}%")
    # find(:all, :conditions => ['title LIKE ?', "%#{search}%"])
    else
      all
    end
  end    

 end

and in new.html.erb:

<div id="header-wrap">
<%= image_tag("walLogotiny.png") %>
<div id="searchbartop">
            <%= form_tag posts_path, :method => :get do%>
            <%= text_field_tag :search, params[:search] ,"size" => 100 %>
            <%= submit_tag "Search", :name => nil %>
            <% end %>
</div>

</div>
<div id="container">
<h2>New Site Submission</h2>
<%= render 'form' %>

<%= link_to 'Back', posts_path %>
</div>
  • 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-29T10:27:10+00:00Added an answer on May 29, 2026 at 10:27 am

    With this line in your model:

      attr_accessible :photo
    

    You make only the photo attribute mass-assignable. All other attributes, including the title, are dropped when you create a new post.

    Try this:

    attr_accessible :photo, :title
    

    It will now accept the title, but not the other attributes.

    edit: didn’t see your own comment above, but you figured it out already.

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

Sidebar

Related Questions

Tried a bunch of things but I can't get it to work consistently amid
So new to objective-c and iphone/ipad development. Trying to get my feet wet with
i get this error, and i don't know how can be solved. I read
I want to upload picture from my_form in jQuery, I tried submit() function it
I need the button submit to be disabled unless JavaScript is on. I tried:
I'm trying to use form submit with jquery without a page refresh as demonstrated
As per the documentation in the following link, we can get the user id
For some reason both the Get and Post fire the first action. public ActionResult
After reading and installing the application on the post at Editing a variable-length list
Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 9828 bytes).

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.