I read a lot of stuff about this, but still i can't fix my error.
Error i got is: Aws::Errors::MissingRegionError (missing region; use :region option or export region name to ENV['AWS_REGION']):
My production.rb :
config.paperclip_defaults = {
:storage => :s3,
:region => 'eu-central-1',
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
I just add: :s3_region => ENV['AWS_REGION'],
to production.rb
then run
heroku config:set AWS_REGION=my_region
Now it upload images properly
Related
I've spent the last day trying to get this to work in my Rails app, but continually get the response:
{"code"=>"E-C-343", "message"=>"Unrecognized JSON Request."}
BancBox's Documentation is pretty light, so I'm at a bit of an impasse on how to solve this.
Does anyone have an example of a successful API call to createClient at BancBox utilizing REST?
My Post API call utilizing HTTParty:
include HTTParty
format :json
def save_with_bancbox(params = {})
post_params = { :authentication => { :apiKey => BANCBOX_KEY,
:secret => BANCBOX_SECRET
},
:subscriberId => BANCBOX_ID,
:firstName => params[:first_name],
:lastName => params[:last_name],
:ssn => params[:ssn],
:dob => params[:dob],
:address => { :line1 => params[:address_line_1],
:line2 => params[:address_line_2],
:city => params[:city],
:state => params[:state],
:zipcode => params[:zipcode]
},
:homePhone => params[:dob],
:email => params[:email]
}
response = HTTParty.post( BANCBOX_REST_URL,
:body => post_params)
logger.debug "Response -- #{response}"
save!
end
Please try the below code after changing apikey, secret and subscriberid
require "net/https"
require 'rubygems'
require 'json'
require 'httparty'
###########################bancbox.rb in config/initializers#################
BANCBOX_API_KEY = "__KEY__"
BANCBOX_API_SECRET = "__SECRET__"
BANCBOX_SUBSCRIBER_ID = "__SUB_ID__"
BANCBOX_API_URL = "https://sandbox-api.bancbox.com/BBXPortRest"
module Bancbox
class API
include HTTParty
debug_output $stdout
base_uri "#{BANCBOX_API_URL}"
def initialize(u=BANCBOX_API_KEY,p=BANCBOX_API_SECRET)
auth = {:apiKey => u, :secret => p}
#options = {:body => {:authentication =>auth,:subscriberId=>BANCBOX_SUBSCRIBER_ID}, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }}
end
#USERS
def create_client(options={})
options = options.merge(#options[:body])
#options.merge!({:body => options.to_json})
response = self.class.post("/createClient",#options)
#required_fields- subscriberId,firstName,lastName,ssn,dob,address,homePhone,email
end
def get_schedules(options={})
#options.merge!({:query => {:subscriberId => BANCBOX_SUBSCRIBER_ID}})
#options.merge!({:query => options})
self.class.post("/getSchedules",#options)
end
end
end
b = Bancbox::API .new
b.create_client({:firstName=> "Bipen",:lastName=> "Sasi",:ssn=>"334-444-4444",:dob=> Date.parse("January 1st 1988"), :address=>{:line1=> "4408 walnut st", :line2=>"apt 3r",:city=> "philly",:state=>"pa",:zipcode=>"19110"}, :homePhone=> "2672551161",:email=>"bipen#lokalty.com"})
I think you should POST the request to
https://sandbox-api.bancbox.com/BBXPortRest/createClient
instead of
https://sandbox-api.bancbox.com/BBXPortRest/
Also make sure to set the content type as application/json
In general, you post your request to https://sandbox-api.bancbox.com/BBXPortRest/<method>
Is there any easy way to include the multiupload feature to NetzkeFormView or GridView(AddInForm)?
My current image uloading field with carrierwave is:
{:name => :image_link, :xtype => :displayfield, :display_only => true, :getter => lambda { |r| %Q(<a href='#{r.image.url}'>Download</a>) if r.image.url }},
{:name => :image, :field_label => "Upload image", :xtype => :fileuploadfield, :getter => lambda { |r| "" }, :display_only => true}
Paperclip gem 3.0.4
When I use flat Paperclip definition in Model (UserDetail has an avatar):
has_attached_file :avatar, :styles => {:medium => "300x300>", : :thumb => "64x64#" }
All images are created in correct proportions.
When I use a custom processor through lambda ( http://www.matthuggins.com/articles/rotating-paperclip-image-attachments-in-rails ):
has_attached_file :avatar, :processors => [:rotator], :styles => lambda { |a| {
:thumb => { :geometry => '64x64#', :rotation => a.instance.rotation, },
:medium => { :geometry => '300x300>', :rotation => a.instance.rotation, }, } }
The image is rotated by the specified amount but all images stay at the same size and proportions as the :original.
Is :geometry the right parameter? Has this changed in later version of Paperclip (I'm unsure of the version of Paperclip used in the web example)?
Any pointers gratefully received
Regards
Peter
one proc per style:
has_attached_file :avatar,
:processors => [:rotator],
:styles => {
:thumb => Proc.new { |a| { :geometry => '64x64#', :rotation => a.instance.rotation } },
:medium => Proc.new { |a| { :geometry => '300x300>', :rotation => a.instance.rotation } }
}
Is it possible to send mailers in the development environment?
I've added this to my development.rb file:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
:address => "mail.email.com",
:port => 25,
:domain => 'email.com',
:user_name => 'email#email.com',
:password => 'password',
:authentication => 'plain',
:enable_starttls_auto => true }
Then I run UserMailer.welcome_email(#user).deliver in rails console which returns #<Mail::Message:2265713480, Multipart: true, Headers: <Date: Thu... but I never actually receive the email. Is there something else I need to configure?
Oh, and if I check ActionMailer::Base.deliveries it returns an empty hash => [].
Needed to add the following to environments/development.rb:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
I am using rails 3.1.0.rc3 with formtastic 2.0.0.rc2 and I am getting this error -
undefined method `inputs' for #<ActionView::Helpers::FormBuilder:0x000001059c2fb0>
Here is the block of code
= form_tag '#', :class => 'formtastic' do
= fields_for CustomFields::Field.new, :builder => Formtastic::Helpers::FormHelper.builder do |g|
= g.inputs :name => :attributes do
= g.input :_alias
= g.input :hint
= g.input :text_formatting, :as => 'select', :collection => options_for_text_formatting, :include_blank => false, :wrapper_html => { :style => 'display: none' }
= g.input :target, :as => 'select', :collection => options_for_association_target, :include_blank => false, :wrapper_html => { :style => 'display: none' }
Is this a bug ?
Thanks, Alex
You are trying to use a formtastic method here. When you are actually in a block for Rails's form builder.
You need semantic_form_for and formtastic in your Gemfile to use f.inputs for example..