gmaps4rails having trouble rendering custom marker images - ruby-on-rails-3

I have 4 types of markers on my map and I am loading an image for each point depending on it's "school type". This is working fine but I'm getting a weird artifact on the map that I don't get when using the standard marker image.
def map
#json = School.where(:disabled => [false, nil]).to_gmaps4rails do |school, marker|
marker.infowindow render_to_string(:partial => "schools/marker", :locals => { :object => school })
if school.school_type_id == 1
marker.picture({ "picture" => view_context.image_path('map_icons/blue_P.png'),"width" => '20',"height" => '34'})
elsif school.school_type_id == 2
marker.picture({ "picture" => view_context.image_path('map_icons/red_C.png'),"width" => '20',"height" => '34'})
elsif school.school_type_id == 3
marker.picture({ "picture" => view_context.image_path('map_icons/yellow_J.png'),"width" => '20',"height" => '34'})
elsif school.school_type_id == 4
marker.picture({ "picture" => view_context.image_path('map_icons/green_I.png'),"width" => '20',"height" => '34'})
end
marker.json({ :id => school.id })
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: #schools }
end
end
Images of the artifact:
http://foa-approved.org/map_artifact1.png
http://foa-approved.org/map_artifact2.png
I am using the css fix for the map controls:
.map_container img {
max-width: none;
}
Can this fix work on the marker image or it is something else entirely?

Related

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

How to call helper method through select_tag

I am trying to call helper method from select_tag. I tried this:
<%= select_tag(:themes, options_for_select({"Black" => "compiled/styles", "Green" => "compiled/styles2"})) %>
When I put alert(this.options[this.selectedIndex].value) instead of calling method, it works. How can I change my code to call the method as desired?
EDIT
I have this on my application.js
$(document).ready(function() {
$('#display_themes').change(function(){
$.ajax({url: '<%= url_for :controller => 'application', :action => 'set_themes()', :id => 'this.value' %>',
data: 'selected=' + this.value,
dataType: 'script'
})
})
});
And in controller I have set_themes methode
def set_themes()
#themes = params[:id]
respond_to do |format|
redirect_to '/galleries'
format.html # index.html.erb
format.xml { render :xml => #themes }
end
end
The problem now is #themes still empty even I change the dropdown
Routes.rb
match '', :controller => 'application', :action => 'set_themes()'
To route to application#set_themes:
match '/set_themes', to: 'application#set_themes', as: :set_themes
With that done, just direct the url in ajax as follows:
$.ajax({url: "<%= set_themes_path %>",
It should be #themes = params[:selected] in your controller based on what you are trying to do in application.js.

Netzke basepack. Need advice with multi uploading fields

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}

Rails - Clean way of calling model method in respond_to differently depending on the format

I have some code like this:
respond_to do |format|
format.html { #all_activities = current_user.recent_activities(#size_per_page,params[:start],nil) }
format.csv { #all_activities = current_user.recent_activities(nil,params[:start],nil); build_activity_csv }
format.xls { #all_activities = current_user.recent_activities(nil,params[:start],nil);
send_data(build_excel_all, :filename => "#{Time.now.strftime('%Y-%m-%d')}_Activity_All.xls", :type => "application/xls", :disposition => 'attachment')
}
format.js { #all_activities = current_user.recent_activities(#size_per_page,params[:start],nil) }
format.pdf { #all_activities = current_user.recent_activities(nil,params[:start],nil); prawnto :filename => "#{Time.now.strftime('%Y-%m-%d')}_Activity_All", :inline => false
}
end
As you see, I am calling the same method in the different formats, but in some cases I use the #size_per_page variable, and sometimes I call the method with nil instead.
Anyone recommend a better, cleaner or non repeating way of doing this?
Thanks
I'd separate that call into a function but that's just me.
Here's how I would do it:
respond_to do |format|
format.html { set_all_activities(#size_per_page) }
format.js { set_all_activities(#size_per_page) }
format.csv do
set_all_activities(nil)
build_activity_csv
end
format.xls do
set_all_activities(nil)
send_data(
build_excel_all,
:filename => "#{Time.now.strftime('%Y-%m-%d')}_Activity_All.xls",
:type => "application/xls",
:disposition => 'attachment')
end
format.pdf do
set_all_activities(nil)
prawnto(
:filename => "#{Time.now.strftime('%Y-%m-%d')}_Activity_All",
:inline => false)
end
end
def set_all_activities(size)
#all_activities = current_user.recent_activities(size, params[:start], nil)
end
I'm assuming params[:start] and the last nil argument are consistent, right?

Devise and Authentication with CURL !

I would like to be able to authenticate through a curl style !
So I would like to get a Token when I signed in :
curl -X POST 'http://localhost:3000/users/sign_in.json' -d 'user[email]=em...#provider.us&user[password]=pass'
But if I perform this action I only get :
{"email":"em...#provider.us","name":"Name of the user"}
How I could add some specific fields like authentication_token ?
Is what I want to do is right ? Is there any other better way to do
this ?
Thanks !
I created a Controller named SessionController
class Users::SessionsController < Devise::SessionsController
append_view_path 'app/views/devise'
def create
respond_to do |format|
format.html { super }
format.json {
warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
current_user.ensure_authentication_token!
render :json => {:user => current_user.api_attributes, :auth_token => current_user.authentication_token}.to_json, :status => :ok
}
end
end
def destroy
respond_to do |format|
format.html { super }
format.json {
warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
current_user.empty_authentication_token!
render :json => {}.to_json, :status => :ok
}
end
end
end
And added this to the root file :
devise_for :users, :controllers => { :sessions => "users/sessions" }
And it works :-)