Remote Server behaving weirdly - ruby-on-rails

I am trying to upload multiple images using paperclip gem. I have controller BatchImagesController, an associate batch images model and an attachment model image_assets. Now the issue is, my app is working fine on localhost in development and production environment. But on Remote server its not uploading images. The database shows batch_images entries but nothing uploads in image_assets. I am unable to debug here. Production log is also not showing anything. I am using ruby 1.9.3 and rails 3.2.13.
Any suggestion what I might be doing wrong?? Is this a mass assignment issue??I have made the
config.active_record.whitelist_attributes = false

Related

Ruby on Rails / Heroku Images not rendering in a staging application

I have a ruby on rails app running in heroku, to render images in the config/production.rb I entered this config.serve_static_assets = true
config.assets.compile = true and I was able to see my images fine, when I created a test app the images were not being rendered. Got any suggestions? I am rendering the images ">
If you are upload images and wants to display it on Heroku application then it won't be happen because heroku is readonly system. You have to upload images to another server like AWS S3 or cloudinary using paperclip/carrierwave gem.
Thanks for all your help forgot to seed my test database, thanks for all your help really appreciate it

Ruby, ActiveRecord: Local rails server updates record attributes whereas the remote server does not

I have a script which sends data from a Windows back end to Heroku. Recently I added four new columns to the object model. For testing each of the properties is updated individually through a cURL request.
On the local rails server (which is identical to the Heroku hosted server) all four new attributes are populated correctly and there are no errors in the logs.
On the Heroku based server when I run the back end script it updates two of the columns but not the other two. In spite of these values not being populated the logs indicate that the process ran successfully with status of 200.
Has anyone experienced something similar to this?
Ok, managed to resolve this issue.
The solution was to run heroku restart. Seemingly since Heroku apps are precompiled the new columns were not being recognised by the app.
Peculiarly, the app should've probably raised an UnknownAttributeError before the fix was applied.
Cheers,
CBusBus.

Rails4 Paperclip attachments not working in production

I'm trying to upload Avatars to Users and it's working in development but not in production
Rails4, Heroku, S3, Paperclip, Devise
Everything is working fine in dev. When I push to Heroku, run Heroku migrate , and try to update devise User page with an attachment(:avatar) image, it returns the image url as missing.
In heroku logs --tail it appears to run normally, even saving the image to S3 (I checked and they are saving in my S3 bucket). Also if I pull pg database I can see the columns in the database associated with attachment images (4 columns). In production the attachment file columns are empty when I check the database, so nothing is going to them, but they are stored in S3.
This is kind of weird? I thought Paperclip Docs say that it will save to database and run validations before sending to server.
My Form
My view (index.html.erb)
<%= image_tag post.user.avatar.url(:thumb) %>
And here's my log after successfully saving to S3 (heroku logs --tail)
If I check the database, the columns for attachments are still nil
what confuses me is that this works in Development but not in production and appears to not have anything to do specifically with an S3 error.
what am I doing wrong??
Well, big time-waster.
I finally got so fed up trying to figure this one out I ended up going through all the motions for a 2nd and 3rd time and for whatever reason, it works now :\
-I added paperclip.rb (empty file) in config/initializers/
-I merged all my safe branches into master.
-Ran bundle install
-Pushed to github
-Ran Git push heroku master
-Ran heroku run rake db:migrate
This is the 3rd time running through those operations so I honestly do not know where the problem was but it is working now.
Thanks #peterept for helping
You form should have enctype="multipart/form-data" and the new version of paperclip force you to have this validation:
validates_attachment_content_type :avatar, :content_type => /\Aimage/.*\Z/
Take a look at their documentation: https://github.com/thoughtbot/paperclip

Spree 2.1 deployment on Heroku

I am trying to deploy an ecomm site I am developing to Heroku.
I am using Rails 4, Spree 2.1 with the Spree_Fancy theme overtop that, S3 for images, and postgres as database in all environments.
The application is working perfectly on my local machine, but when I deployed it to Heroku, the front end breaks. The app runs via Heroku, but there is no styling at all, no theme, nothing. Just plain text and "no products found" message.
I expected there to be no images (since none had yet been uploaded to s3), but there were no products either, even though the db migrations ran.
Any ideas of what I am missing?
I've just answered on another thread the same problem scenario. Hope it helps.
Broken spree_fancy layout on heroku

Ruby on Rails. How do I change view file in production without restarting server

I made feature that allows to change one of view files through browser.
It changes file and doesn't use DB. In development mode all works well.
But as far as I know rails caches all files in production mode.
Does somebody know solution?
I have found this post
http://railshints.tumblr.com/post/1559660060/reload-rails-templates-dynamically-in-production-mode but it seems not work or I do something wrong.
I use Rails 2.3.5

Resources