Git Product home page Git Product logo

carmen-rails's People

Contributors

bshelton229 avatar cdainmiller avatar ecbypi avatar jgrevich avatar jim avatar kevinwmerritt avatar martinbcg avatar mcrowe avatar petergoldstein avatar rdsoze avatar tinynumbers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

carmen-rails's Issues

No translation in forms

Am using the country_select input in one of my forms and it doesn't apply the locale.
I even tried setting it using Carmen.i18n_backend.locale = :es in the controller in the view and still no luck. Don't know if its a bug or just me doing something wrong.

Any suggestions?

thanks

Rails extremely slow with carmen-rails gem

When I run 'rails r' or 'rails s' on my Windows 7 64bit machine, it takes 3 minutes before something happens. This has only begun recently. 'gem install' and 'bundle install' still run at normal speed.

In order to find out what caused the problem I upgraded to the latest Rails version (3.2.13) and Ruby Installer 1.9.3-p392. That didn't help. Then I got a tip to look at my gemfile. So I started removing gems from my gemfile. Once I commented out gem 'carmen-rails' startup times where back to normal.

This is only recently. It has worked just fine, as I am using carmen-rails in production. I tried going back to an older version with gem 'carmen-rails', '1.0.0.beta2' but that didn't help either.

I also had an issue with "Too many files open", that also pointed to carmen-rails. Any idea what might be going on? Any recent changes that might explain this behavior? Thanks.

Locale files from carmen are loaded after rails app initializes

Hi,

we have a problem with adding custom translation to some Carmen state. We added translation to our locale file but it didn't change anything. I think the problem lies at how carmen-rails adds locale files from Carmen to rails I18n.load_path. It adds the files to config.i18n.load_path withing its Railtie and that causes the files are added to app I18n.load_path after the app locales so it rewrites any locale keys app defines.

I just wanted to check, isn't this for some intention i just can't think of right now? If not i propose to change it. I actually tried it at my fork masa331/carmen-rails. I changed the Railtie a bit and it's all good.

If it's all right should i make a pull request?

Country name 3 letters in drop down

Can we show 3 letter country names in the select field drop down list(USA, CAN...) . Right now values are showing in default 2 letter names .

There will be some cases where we need to pass 3 letter country names .

= f.country_select :country, {priority: %w(US CA)}, prompt: 'Please select a country'

Thanks in advance .

how to pass a class

<%= f.country_select :country, include_blank: t('options.choose'), class: "my_fancy_class" %>

doesn't work :(

_enabled: false on subregions only works half the time?

For several countries, I'd like to suppress all subregions. I set the _enabled attribute to false on all subregions, but only every other one is actually suppressed. For example:

bd.yml


---
- code: '1'
  _enabled: false
- code: '2'
  _enabled: false
- code: '3'
  _enabled: false
- code: '4'
  _enabled: false
- code: '5'
  _enabled: false
- code: '6'
  _enabled: false

Rails console:

> Carmen::Country.coded("BD").subregions.map &:code
["2", "4", "6"]

Is there better way to suppress all subregions?

translation missing subregions

Hi, I'm trying to run the "locale =: es" in subregions, but it shows "translation missing: es.worl.eu. ....". When setting "locale =: en" me going great the subregions.

Regards,

country_select in nested model doesn't get filled when editing record

I have a Customer model with an associated Address model. The Customer model accepts nested attributes for the Address. The Address has fields for country and region.

If I create a new Customer with it's associated Address, the Country and Region are saved to the database, but when I edit a record, the fields are not getting filled, i.e., the saved Country and Region are not selected.

Am I using this wrong or is it a bug, because when the country fields are in the main model and not in the associated model, everything works fine.

The view:

<%= semantic_form_for [:admin, @customer] do |f| %>
    <%= f.inputs "Address" do %>
        <%= f.semantic_fields_for :address, f.object.address || f.object.build_address do |address| %>
            <%= address.input :country %>
            <li id="customer_address_attributes_region_input" class="country input optional">
                <%= address.label :region, :class => 'label' %>
                <%= render partial: 'region_select', locals: {country: address.object.country} %>
            </li>
        <% end %>
    <% end %>
<% end %>

And the partial _region_select.html.erb:

<div id="address_region_wrapper">
    <% country ||= params[:country] %>
    <% country = Carmen::Country.coded(country) %>

    <% if country.nil? %>
        <em>Please select a Country above.</em>
    <% elsif country.subregions? %>
        <%= subregion_select(:customer_address_attributes, :region, country, {}, {:name => "customer[address_attributes][region]"}) %>
    <% else %>
        <%= text_field(:customer_address_attributes, :region, :name => "customer[address_attributes][region]") %>
    <% end %>
</div>

how to give state short names.

I have given this in my view:

<div class="input-control select country_input" data-role="input-control">
      <%= f.select :country, region_options_for_select(only_us_and_france),:prompt => 'Select Country' %>
</div>               
<div class="input-control select state_input" data-role="input-control">
          <%= render partial: 'subregion_select', locals: {parent_region: f.object.country} %>
 </div>

and in my subregion partial this:

<div id="account_state_code_wrapper" >
  <% parent_region ||= params[:parent_region] %>
  <% country = Carmen::Country.coded(parent_region) %>

  <% if country.nil? %>
      <div style="display: none">State</div>
  <% elsif country.subregions? %>
      <%= subregion_select(:account_detail, :state_code, parent_region) %>
  <% else %>
      <%= text_field(:account_detail, :state_code) %>
  <% end %>
</div>

So its showing the name of countries and states but I want to show in my select option like Ak and Al so on for state also.
Please help me out. Thanks in advance.

subregion_select dropdown has value numeric instead of alphabet code

Hi there,
As part of testing just observed that for country Denmark, the subregion select dropdown has value numeric.

State Hovedstaden Midtjylland Nordjylland Sjælland Syddanmark

On saving it, the same numeric value is being saved in table.

Is it normal behaviour, any fix will be really appreciated.

form_tag usage

I have a form that doesn't reference an object (it is a form that is submitted to Recurly), so I am using a form_tag instead of form_for. How do I specify the parent_region for the the subregion select if I can't reference f.object.country_code?

add carmen-rails to rubygems

carmen-rails will only install with bundler when the git location of both carmen and carmen-rails 1.0.0.pre is specified my gem file.

Mexico out of order in locale es

When using the spanish locale the select order is not ok. Mexico appears after Mozambique when it should come after Mayotte. Works well when using en locale. Åland (AX) appears at end of list regardless of en or es locale.

--- MX issue

Mauricio Mauritania Mayotte Micronesia Moldavia Mongolia Montenegro Montserrat Mozambique México Mónaco Namibia

---- AX issue

Zambia Zimbabue Åland

Sort order in country_select

ruby 1.9.3p194
rails 3.2.3
carmen-rails 1.0.0.beta3

I am a little confused about the sort order of the countries generated by country_select. The sorting algorithm from https://github.com/jim/carmen-rails/blob/ada9fc20b65123629fb0831b5997f81f9bfb2a5e/lib/carmen/rails/action_view/form_helper.rb#L88 behaves like this on the command line:

Carmen::World.instance.subregions.sort{|a, b| a.name.unpack('U').to_s <=> b.name.unpack('U').to_s}.map{|r| [r.name, r.name.unpack('U').to_s]}
 => [... ["Greece", "[71]"], ["Germany", "[71]"], ["Guatemala", "[71]"] ... ]

As you can see, the order isn't correct because all countries with "G" have the same sort key "[71]".

undefined method `subregions'

using subregion_select(@object, :region, {priority: ['US', 'CA']}, class: 'region') in my form returns
undefined methodsubregions' for {:priority=>["US", "CA"]}:Hash`
but the below one works:

subregion_select(@object, :region, 'US', class: 'region')

localized country_select

How do you use country_select in a different language. I tried Carmen.i18n_backend.locale=:es but the select is still in English.

Thanks!

carmen rails

hi i got this error NoMethodError at /signup
undefined method `downcase' for nil:NilClass

<% parent_region ||= params[:parent_region] %> this---> <% country = Carmen::Country.coded(parent_region) %>
  <% if country.nil? %>
   <em>Please select a country above</em>
 <% elsif country.subregions? %>
   <%= subregion_select(:order, :state_code, parent_region) %>

Rails 4 Params

I followed the instructions to the letter but I'm getting the following params:

Started GET "/jobs/subregion_options?parent_region=BR" for 127.0.0.1 at 2013-12-13 21:01:09 +0000
Processing by JobsController#show as HTML
Parameters: {"parent_region"=>"BR", "id"=>"subregion_options"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Job Load (0.2ms) SELECT "jobs".* FROM "jobs" WHERE "jobs"."id" = ? LIMIT 1 [["id", "subregion_options"]]
Completed 404 Not Found in 4ms

ActiveRecord::RecordNotFound (Couldn't find Job with id=subregion_options):
app/controllers/jobs_controller.rb:75:in `set_job'

Anyone else had this issue, why is it assigning it to my jobs id? Might be a newbie question.

US states missing

Jim,

I am using this gem and it seems like Mississippi and Missouri are missing from the states list. Can you verify if this is the same for you?

subregion_select helper doesnt allow to give classes

We couldn't pass class names in subregion_select helper;

tried below samples:

subregion_select(:shipping_address, :state_id, parent_region, :html_options => {:class => 'form-control'})
AND
subregion_select(:billing_address, :state_id, parent_region, class: 'form-control')

remove pg from Gemfile

Could you remove pg from your Gemfile ? It makes bundle install a pain when you do not have postgre and according to config /database.yml it is not necessary (SQLite)....

Carmen with devise(Ruby on rails) country_code: nil

Hey Everyone, I'm new and I have a basic question

When I create a new user with devise using carmen-rails with Rails 4, country_code and states_code don't pass

Both country_code and state_code are permitted

Here are my codes:

in Devise registration:

= f.label :country_code
= f.country_select :country_code, {priority: %w(US CA), prompt: "Please select your country"}, :style => "width:170px;float:left;font-size:14px;", :type => 'text'
= f.label :state_code
= render partial: '/users/subregion_select', locals: {parent_region: f.object.country_code}

in users/ _subregion_select:

<% parent_region ||= params[:parent_region] %> <% unless parent_region.nil? %>
<% country = Carmen::Country.coded(parent_region) %>
<% end %>

<% if country.nil? %>
Please select a country above
<% elsif country.subregions? %>
<%= f.subregion_select(:user, :state_code, parent_region) %>
<% else %>
<%= text_field(:user, :state_code) %>
<% end %>

in users.js.coffee

$('select#user_country_code').change (event) ->
select_wrapper = $('#user_state_code_wrapper')

$('select', select_wrapper).attr('disabled', true)

country_code = $(this).val()

url = "/users/subregion_options?parent_region=#{country_code}"
select_wrapper.load(url)

in routes.rb

get '/users/subregion_options' => 'users#subregion_options'

in users controllers:

def subregion_options
render partial: 'subregion_select'
end

On my console, all the data are saved except for country_code: nil (even though I put United States) and the states_code is not generated when I select a country.

Is that because I should need to use Formstatic?

Thank you for your help :)

Fails to start

/Users/andriytyurnikov/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/carmen-rails-958b23d8e0d5/lib/carmen-rails.rb:8:in <class:Railtie>': undefined methodi18n_backend' for Carmen:Module (NoMethodError)

gem needs initializer or something?

undefined method `to_region_select_tag'

Dear all

I'm sorry if my error sound silly. I'm getting this error while implementing carmen on my rails app:

undefined method to_region_select_tag' for #ActionView::Helpers::Tags::Base:0x5d83a18
`

this is my form code
`
<%= simple_form_for @practitioner do |f| %>
<% if practitioner.errors.any? %>


<%= pluralize(practitioner.errors.count, "error") %> prohibited this practitioner from being saved:

  <ul>
  <% practitioner.errors.full_messages.each do |message| %>
    <li><%= message %></li>
  <% end %>
  </ul>
</div>

<% end %>

<%= f.label :firstName %> <%= f.text_field :firstName %>
<%= f.label :LastName %> <%= f.text_field :LastName %>
<%= f.label :contactNum %> <%= f.text_field :contactNum %>
<%= f.label :country %>
<%= f.country_select :country, priority: %w(US CA), prompt: 'Please select a country' %>
<%= f.label :state %> <%= f.text_field :state %>
<%= f.label :location %> <%= f.text_field :location %>
<%= f.submit %>
<% end %> `

Rails 5 support, fix

If anyone else has issues getting this to work in Rails 5, I was able to get it by forking and adding this to form_helper.rb after line 223:

if Rails::VERSION::MAJOR == 5
      module Tags
        class Base
          def to_region_select_tag(parent_region, options = {}, html_options = {})
            html_options = html_options.stringify_keys
            add_default_name_and_id(html_options)
            options[:include_blank] ||= true unless options[:prompt]

            value = options[:selected] ? options[:selected] : value(object)
            priority_regions = options[:priority] || []
            opts = add_options(region_options_for_select(parent_region.subregions, value, 
                                                        :priority => priority_regions), 
                               options, value)
            select = content_tag("select", opts, html_options)
            if html_options["multiple"] && options.fetch(:include_hidden, true)
              tag("input", :disabled => html_options["disabled"], :name => html_options["name"], 
                           :type => "hidden", :value => "") + select
            else
              select
            end
          end
        end
      end
    end

On the line with options[:include_blank] ||= true unless options[:prompt] || select_not_required?(html_options), I had to remove select_not_required? as this seems to be deprecated. Seems to work without, but not sure if it should be replaced with something else.

country_select options being rendered in HTML

For some reason on our staging environments when I use this stynax (with HAML):

= f.country_select(:country, { priority: ['US', 'CA'], prompt: 'Select Country' })

the options are rendering inside the HTML:

screen shot 2014-04-28 at 11 33 35 am

We are using Ruby 1.9.3 and Rails 3.2.17. I cannot seem to reproduce this locally. I am using version 1.0.1 of the gem.

Using Gem with Simpleform

I am somewhat new to rails and have a rather large form I have done in Simple_form. How would I use this gem to get country and state dropdown list. I tried what was written on the instructions but I get an error regarding number of arguments.

Namespace conflict with ActiveScaffold

we use ActiveScaffold(AS) for our admin controllers, and want to use Carmen for country selects in the rest of the site. In development env, Carmen worked as expected, but not in test mode. This is because Rails eager loads everything in the app directory, which includes the admin controllers, which loads the AS helpers. So presumably we would see this in production, which eager loads app files as well.

On line 177 of form_helper.rb, you call @template.country_select, which calls AS's version instead of Carmen's version on line 50.

Due to this, we won't be able to use Carmen right now, as ripping out AS(which I'd honestly prefer), would just cause a bigger headache.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.