Netzke basepack. Need advice with multi uploading fields - ruby-on-rails-3

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}

Related

Paperclip + S3 Amazon region error

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

Netzke column locking

I saw a feature in Ext JS document - http://dev.sencha.com/deploy/ext-4.0.1/examples/grid/locking-grid.html. We can lock a column by set the option "locked" according the document, but when I did this in Netzke Grid, the grid disappears. Is there any specific method to achieve this. Below the sample code is given,
def configure(c)
super
c.model = "Product"
c.title = "Product List"
c.columns = [
{
:name => :name,
:text => "Name",
:read_only => true,
:locked => true
},
{
:name => :price,
:text => "Price"
},
{
:name => :date,
:text => "Date"
}
]
end

elasticsearch geo_distance query give me error how to write geo_distance query?

I have a table, schools with the fields: id, name, address, city, state, zip, latitude and longitude.
I want to search for schools within 12km by giving latitude and longitude; I am using this query but it's not working.
curl -X GET "http://localhost:9200/schools/school/_search?=true" -d '{"filter" : {"geo_distance" : {"distance" :"12km", "location": "40,-70"}}}'
I get the following error:
{
"error":"SearchPhaseExecutionException[
Failed to execute phase [query], total failure;
shardFailures {[_na_][schools][0]: No active shards}{[_na_][schools][1]:
No active shards}{[_na_][schools][2]: No active shards}{[_na_][schools][4]:
No active shards}{[WJV55VsxQU-XW8VPmXImwA][schools][3]:
RemoteTransportException[[Archie Corrigan][inet[/192.168.1.109:9300]][search/phase/query]]; nested:
SearchParseException[[schools][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [
{\"filter\" :
{\"geo_distance\" :
{\"distance\" :\"12km\", \"location\": \"40,-70\"}
}
}]
]
]; nested: QueryParsingException[[schools] failed to find geo_point field [location]];}]",
"status":500
}
model configuration in rails
# ElasticSearch integration
include Tire::Model::Callbacks
include Tire::Model::Search
include Search::ReloadHelper
tire do
settings({
:analysis => {
:filter => Search::Filters.hs_name_filters,
:analyzer => Search::Analyzers.hs_name_analyzers
}
})
mapping do
indexes :id, :type => 'integer', :index => :not_analyzed
indexes :name, :type => 'string', :analyzer => :hs_name_analyzer
indexes :address, :type => 'string', :index => :not_analyzed
indexes :city, :type => 'string', :analyzer => :hs_name_analyzer
indexes :state, :type => 'string', :index => :not_analyzed
indexes :zip, :type => 'integer', :index => :not_analyzed
indexes :location, :type => 'geo_point', :lat_lon => true
end
end
def to_indexed_json
{
:id => id,
:name => name,
:address => address,
:city => city,
:state => state,
:zip => zip,
:location => {
:lat => latitude,
:lon => longitude
}
}.to_json
end
How can I get this to work?

Paperclip Rails 3.2.2 Not Rotating and Resizing

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 } }
}

rails3.1 and formtastic 2.0.0.rc2 - undefined method `inputs'

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..