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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:29:37+00:00 2026-05-22T14:29:37+00:00

I am trying to implement a feature in my app where a user posts

  • 0

I am trying to implement a feature in my app where a user posts a message along with an image.

This is something similar to what is there in www.diasp.org .

I dealing with a pretty much outdated configuration of Rails 2.0.2 and Ruby 1.8.7 , both running on Ubuntu 10.04 OS for project specific purposes.

Initially, I found a problem in finding an appropriate plugin for paperclip which would suit the above configuration needs.

I am finally making use of this commit of paperclip:-

https://github.com/thoughtbot/paperclip/commit/d177c8f838458348a9f4d1fe41918c5bd99a989c .

I have been able to implement a basic POC successfully without any issues whatsoever with this plugin and thought its time to do the same in my project app.

The current problem I am facing is that on submitting a post message, I am unable to figure out where I am going wrong as in terms of what is obstructing the photo to be passed as a params to the group_post attribute that I am making use of.

I am having all this in a partial…. The part of the code that would accept an image and a message is like this…

<%if @current_user.is_an_existing_member_of_group(@investor_group)%>
<%form_for  :group_post, :url => {:action => :post_message, :id => params[:id]},:html => {:multipart => true, :id => 'new_post'} do |f| -%>
    Start Discussion:<%=f.text_field :message%>
   <%=f.file_field :photo%>
   <%=f.submit "Post" %>
  <%end%>

<div id = "latest_post"> </div>
<%for a in @group_all_posts %>
<%= image_tag a.photo.url %>
<%= a.message %> by <%=  Investor.find(a.post_by).first_name %> <div class ="contentdispgrp" id="style_chck"> <%=  distance_of_time_in_words(a.created_at,Time.now) %> ago </div><br/><br/> <hr/>
<%end%>

I actually tried comparing this with the view file in my POC which successfully uploaded images for me and even displayed the same. The new.html.erb file of my POC looks like this:-

<h1>New post</h1>

<%= error_messages_for :post %>

<% form_for :post, :url => {:action => :create}, :html => { :multipart => true } do |f| %>
  <p>
    <b>Message</b><br />
    <%= f.text_field :message %>
  </p>

  <%= f.file_field :photo%>

  <p>
    <%= f.submit "Create" %>
  </p>
<% end %>

<%= link_to 'Back', posts_path %>

A glimpse of what is being passed as part of the params as per the log looks something like this wrt the POC running:-

Case 1

   Processing PostsController#create (for 127.0.0.1 at 2011-05-20 15:55:00) [POST]
      Session ID: BAh7ByIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7ADoMY3NyZl9pZCIlZjQ5NWYyNDAxNDVjNmZkOGU5%0AZjM0ZjJjOTZlOTRlM2I%3D--a30d15cac639bde46b5d57218084da993caf094b
      Parameters: {"commit"=>"Create", "post"=>{"photo"=>#<File:/tmp/CGI20110520-5743-u5iauq-0>, "message"=>"abc1"}, "authenticity_token"=>"1c19641bd05adb24157f5f1d04b4c8e072cb7ebe", "action"=>"create", "controller"=>"posts"}
      Post Columns (0.000975)   SHOW FIELDS FROM `posts`
      SQL (0.000199)   BEGIN
      Post Create (0.000332)   INSERT INTO `posts` (`created_at`, `photo_file_size`, `photo_file_name`, `updated_at`, `photo_content_type`, `photo_updated_at`, `message`) VALUES('2011-05-20 15:55:00', 83794, 'Water lilies.jpg', '2011-05-20 15:55:00', 'image/jpeg', NULL, 'abc1')
      SQL (0.059184)   COMMIT
    Redirected to http://localhost:4004/posts/22
    Completed in 0.33966 (2 reqs/sec) | DB: 0.06069 (17%) | 302 Found [http://localhost/posts]

Case 2

A glimpse of what is being passed as part of the params as per the log looks something like this wrt the project app running:-

Processing GroupsController#post_message (for 127.0.0.1 at 2011-05-20 15:42:52) [POST]
  Session ID: 0d806dc029197b7db11552a447dd329e
  Parameters: {"group_post"=>{"message"=>"hi5"}, "action"=>"post_message", "id"=>"10", "controller"=>"groups"}
  Investor Columns (0.002125)   SHOW FIELDS FROM `investors`
  Investor Load (0.000173)   SELECT * FROM `investors` WHERE (`investors`.`id` = 397) LIMIT 1
  InvestorGroup Columns (0.001198)   SHOW FIELDS FROM `investor_groups`
  InvestorGroup Load (0.000114)   SELECT * FROM `investor_groups` WHERE (`investor_groups`.`id` = 10) 
  InvestorGroup Load (0.000207)   SELECT investor_groups.* FROM investor_groups INNER JOIN investor_group_members ON investor_groups.id = investor_group_members.investor_group_id WHERE ((investor_group_members.investor_id = 397)) 
  GroupPost Columns (0.002383)   SHOW FIELDS FROM `group_posts`
  SQL (0.000111)   BEGIN
  GroupPost Create (0.000342)   INSERT INTO `group_posts` (`post_by`, `created_at`, `photo_file_size`, `photo_file_name`, `updated_at`, `investor_group_id`, `photo_content_type`, `message`) VALUES(397, '2011-05-20 15:42:53', NULL, NULL, '2011-05-20 15:42:53', 10, NULL, 'hi5')
  SQL (0.069269)   COMMIT
Rendering groups/post_message
  Investor Load (0.000194)   SELECT * FROM `investors` WHERE (`investors`.`id` = 397) 
Completed in 0.13884 (7 reqs/sec) | Rendering: 0.00845 (6%) | DB: 0.07612 (54%) | 200 OK [http://localhost/us/groups/post_message/10]

Kindly observe the difference between Case 1 and Case 2.

The code in my model looks like this:-

class GroupPost < ActiveRecord::Base 
  has_many :group_comments
  belongs_to :investor_group
  validates_presence_of :message
  has_attached_file :photo #,  :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

I would like to mention this, this something weird I have observed earlier when dealing with paritals.. something i never expected would behave as such..

I had implemented auto complete previously using a partial, but once I added a comment to this partial documenting whom this file was added by and what was this file about.. Believe it or not.. the Auto Complete stopped working for me…!! . It worked soon after removing the comments. The syntax of the comments I used was <!-- -->

Can I expect similar behavior wrt this case for some reason I am currently unaware of…??

I understand I can’t expect many things working for me with the commit version I am using , but since the basic functionality is working in the POC, I wonder what is obstructing the same to work in my project app..

Please guide me on where I could be going wrong…, Its urgent..

Kindly let me know if you need any other part of the code..

Thanks a lot…

  • 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-22T14:29:38+00:00Added an answer on May 22, 2026 at 2:29 pm

    In the code that doesn’t work, you have:

    :html => {:multipart => 'true'}
    

    but it should be

    :html => {:multipart => true}
    

    as it is in the code that works.

    Every time I’ve run into this problem, it has been because of some typo around the multipart option.

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

Sidebar

Related Questions

I am trying to implement the AudioFileStreamSeek feature on my streaming app. But there
I'm trying to implement a feature similar to StackOverflow's tag feature. That a user
I'm trying to implement an auto-save feature in a Knockout.js app. Is there a
I am trying to implement a bulk update feature in a Rails app, the
I am trying to implement a feature similar to the Related Questions on StackOverflow,
I am trying to implement a feature similar to the "Related Questions" on Stackoverflow.
I am trying to implement a similar feature like the autosuggest feature for tags
All I am currently trying implement something along the lines of dim l_stuff as
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I'm trying to implement this feature . I created a resource and set it

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.