Coder Social home page Coder Social logo

foundation_rails_helper's Introduction

Foundation Rails Helper Build Status

Gem for Rails 4.1+ applications that use the excellent Zurb Foundation framework.

Includes:

  • A custom FormBuilder that generates a form using the Foundation framework classes. It replaces the current form_for, so there is no need to change your Rails code. Error messages are properly displayed.

  • A display_flash_messages helper method that uses Zurb Foundation Callout UI.

Installation

Add this line to your application's Gemfile:

gem 'foundation-rails', '~> 6.0' # required
gem 'foundation_rails_helper', '~> 3.0'

And then execute:

$ bundle

Compatibility

  • Only Rails 4.1/4.2/5/6, and Foundation 6 are fully supported
  • Some features may work with Foundation 5 and older, but results may vary, and markup which exists only for those versions will be gradually removed
  • Legacy branches exist for Rails 3, 4.0, and Foundation 5 (see the rails3, rails4.0, and foundation-5 branches). These are not actively supported, and fixes are not retroactively applied, but pull requests are welcome.
  • We test against ruby versions 2.1 and up. This gem may still work fine on 1.9.3, but your mileage may vary

Screenshots

Forms

A classic devise sign up view will look like this:

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
  <%= f.email_field :email %>
  <%= f.password_field :password %>
  <%= f.password_field :password_confirmation %>

  <%= f.submit %>
<% end %>
Form Form with errors

Flash messages

Flash-message

Usage

Flash Messages

To use the built in flash helper, add <%= display_flash_messages %> to your layout file (eg. app/views/layouts/application.html.erb).

form_for

Form_for wraps the standard rails form_for helper.

<%= form_for @user do |f| %>
  ...
<% end %>

generates:

<form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
  ...
</form>

text_field and Field Helpers

Field helpers add a label element and an input of the proper type.

f.text_field :name

generates:

<label for="user_email">Name</label>
<input id="user_name" name="user[name]" type="text">

Preventing the generation of labels can be accomplished three ways. To disable on a form element:

f.text_field :name, label: false

For all form elements, add the option: auto_labels: false to the form helper. To disable for all forms in you project, use the auto_labels config option, see the Configuration section for more information.

Change the label text and add a class on the label:

f.text_field :name, label: 'Nombre', label_options: { class: 'large' }

If the help_text option is specified

f.text_field :name, help_text: "I'm a text field"

an additional p element will be added after the input element:

<p class="help-text">I'm a text field</p>

Submit Button

The 'submit' helper wraps the rails helper and sets the class attribute to "success button" by default.

f.submit

generates:

<input class="success button" name="commit" type="submit" value="Create User">

Specify the class option to override the default classes.

Errors

On error,

f.email_field :email

generates:

<label class="is-invalid-label" for="user_email">Email</label>
<input class="is-invalid-input" id="user_email" name="user[email]" type="email" value="">
<small class="form-error is-visible">can't be blank</small>

The class attribute of the 'small' element will mirror the class attribute of the 'input' element.

If the html_safe_errors: true option is specified on a field, then any HTML you may have embedded in a custom error string will be displayed with the html_safe option.

Prefix and Postfix

Simple prefix and postfix span elements can be added beside inputs.

f.text_field :name, prefix { value: 'foo', small: 2, large: 3 }

generates

<div class="row collapse">
  <div class="small-2 large-3 columns">
    <span class="prefix">foo</span>
  </div>
  <div class="small-10 large-9 columns">
    <input type="text" name="user[name]" id="user_name">
  </div>
</div>

Configuration

Add an initializer file to your Rails app: config/initializers/foundation_rails_helper.rb containing the following block:

FoundationRailsHelper.configure do |config|
  # your options here
end

Submit Button Class

To use a different class for the submit button used in form_for, add a config named button_class:

# Default: 'success button'
config.button_class = 'large hollow secondary button'

Please note, the button class can still be overridden by an options hash.

Ignored Flash Keys

The flash helper assumes all flash entries are user-viewable messages. To exclude flash entries which are used for storing state (e.g. Devise's :timedout flash) you can specify a blacklist of keys to ignore with the ignored_flash_keys config option:

# Default: []
config.ignored_flash_keys = [:timedout]

Auto Labels

If you prefer to not have the form builder automatically generate labels, set auto_labels to false.

# Default: true
config.auto_labels = false

Contributing

See the CONTRIBUTING file.

Copyright

Sébastien Gruhier (http://xilinus.com) - MIT LICENSE

foundation_rails_helper's People

Contributors

adriancuadros avatar alecslupu avatar bitdeli-chef avatar chilian avatar cndreisbach avatar collimarco avatar copiousfreetime avatar dgmstuart avatar djkz avatar dropletzz avatar dsandstrom avatar erictheise avatar frenkel avatar jbhannah avatar jbigler avatar jconley88 avatar jeffse avatar joewoodward avatar keilmillerjr avatar mattgibson avatar michaelwhi avatar oriolgual avatar patricklindsay avatar potomak avatar sgruhier avatar shingara avatar sonicblend avatar toommz avatar travishaynes avatar werebus 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  avatar  avatar

foundation_rails_helper's Issues

Radio button not rendering for nested attributes

When I try to render a radio button for a nested attribute it simply does not appear.
This works.
<%= f.radio_button(:foo, "Yes") %>

This doesn't

 <%= f.fields_for :bar_model do | bar_model | %>
   <%= bar_model.radio_button(:baz, true, text: 'Yes') %>

The label appears but the HTML for the radio button is not rendered. Any ideas?

flash_helper only renders standard color.

redirect_to path, notice: "success"

passes notice as a string so always defaults to standard color.

If you run into this issue changing

key_matching[key]

to

key_matching[key.to_sym]

will fix this.

Don't know if this is affecting anyone else so I'm not submitting a pull request.

Needs a version bump.

I've just been scratching my head as to why prefix/postfix wasn't working even though it is documented.

It seems that you haven't done a version bump for a while now. master is no longer the same as version 1.0.0

There should be a version bump for each PR introduced.

For any one else trying to get prefix/postfix working, for now you can use the master branch

gem 'foundation_rails_helper', git: 'https://github.com/sgruhier/foundation_rails_helper.git', branch: 'master'

Fix deprecations: and_return { } -> and_return(value)

and_return { value } is deprecated. Use and_return(value) or an implementation block without and_return instead. Called from /home/me/Projects/gems/foundation_rails_helper/spec/support/mock_rails.rb:133:in `mock_everything'.

and_return without arguments is deprecated. Remove the and_return. Called from /home/me/Projects/gems/foundation_rails_helper/spec/support/mock_rails.rb:114:in `mock_everything'.

Overriding/preventing auto labels

Is there a way to prevent form_for from creating labels in addition to the ones I already have defined in my layout? I've not found a way to prevent this behavior.

Thanks

Rails 4 support

It would be awesome if you could please update your gem to support Rails 4. I think it's just a gemspec issue:

Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
foundation_rails_helper (>= 0) ruby depends on
actionpack (~> 3.0) ruby

rails (= 4.0.0) ruby depends on
actionpack (4.0.0)

Make error_for method in form_builder public

Is there a compelling reason to keep the errors_for method in FormBuilder private? I can see a use for this in my own code, where I want to be able to display the error on a property that isn't directly on my form. It's already coded here with the styling appropriate for Foundation, so I'd hate to have to duplicate the code in my own project just to use it.

Way back when, Rails v2 had a method named error_messages_for that would display these errors, but it was removed because it hardcoded certain html and styling. That shoudn't be a problem here, because we want to hardcode the Foundation styling.

Allow configuration of text_field default behavior or disable helper on some forms

I like this helper, but I don't think that forcing f.text_fieldto produce the label by default is always good.

I am forced to add the option label: falseto a lot of labels.

Another option, even better, would be to allow to disable the entire custom helper on some forms. For example when I want to use the normal rails helper (not the modified version provided by this gem) I can write:

form_for @example, {foundation_rails_helper: false}

Or maybe do not override form_forbut add a form_with_helper_for.

Radio button not rendering for nested attributes

When I try to render a radio button for a nested attribute it simply does not appear.
This works.
<%= f.radio_button(:foo, "Yes") %>

This doesn't

 <%= f.fields_for :bar_model do | bar_model | %>
   <%= bar_model.radio_button(:baz, true, text: 'Yes') %>

The label appears but the HTML for the radio button is not rendered. Any ideas?

form_for fails on Spree with "undefined method `human_attribute_name' for NilClass:Class" for any field

Trying to use your helpers on Spree. Finding that it works great on some forms, but on following login form, it fails with the above error. The form works fine if I use form_for_with_foundation.

<%= form_for(:spree_user, :url => spree.spree_user_session_path) do |f| %>
  <div id="password-credentials">
    <p>
      <%= f.email_field :email %>
    </p>
    <p>
      <%= f.password_field :password, :class => 'title', :tabindex => 2 %>
    </p>
  </div>
  <p>
    <label>
      <%= f.check_box :remember_me %>
    </label>
  </p>

  <p><%= f.submit Spree.t(:login), :class => 'tiny round button', :tabindex => 3 %></p>
<% end %>

form_for fails on Spree with "undefined method `human_attribute_name' for NilClass:Class" for any field

Trying to use your helpers on Spree. Finding that it works great on some forms, but on following login form, it fails with the above error. The form works fine if I use form_for_without_foundation.

<%= form_for(:spree_user, :url => spree.spree_user_session_path) do |f| %>
  <div id="password-credentials">
    <p>
      <%= f.email_field :email %>
    </p>
    <p>
      <%= f.password_field :password, :class => 'title', :tabindex => 2 %>
    </p>
  </div>
  <p>
    <label>
      <%= f.check_box :remember_me %>
    </label>
  </p>

  <p><%= f.submit Spree.t(:login), :class => 'tiny round button', :tabindex => 3 %></p>
<% end %>

Exception when a "value" option is set on a Rails label helper.

Using my fork https://github.com/paulwittmann/foundation_rails_helper (which only updated the tzinfo gem) and Rails 4.1.rc1, I get the following error:

NoMethodError - undefined method `html_safe' for {:value=>false}:Hash:
 () Users/paul/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/foundation_rails_helper-03f1be5eb06c/lib/foundation_rails_helper/form_builder.rb:19:in `label'

Everything works fine withe the lastest release from Ruby gems (0.4).

My view code:

= form_for @order do |f|
  %fieldset
    = f.label :custom_box_design, value: false do
      = f.radio_button :custom_box_design, false, checked: [email protected]_box_design

Full stack trace:

Started GET "/orders/3/edit" for 127.0.0.1 at 2014-03-27 23:31:56 +0100
Processing by OrdersController#edit as HTML
  Parameters: {"id"=>"3"}
  Order Load (0.4ms)  SELECT  "orders".* FROM "orders"  WHERE "orders"."id" = $1 LIMIT 1  [["id", 3]]
  Rendered orders/edit.html.haml within layouts/application (6.5ms)
Completed 500 Internal Server Error in 12ms

NoMethodError - undefined method `html_safe' for {:value=>false}:Hash:
   () Users/paul/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/foundation_rails_helper-03f1be5eb06c/lib/foundation_rails_helper/form_builder.rb:19:in `label'
  app/views/orders/edit.html.haml:4:in `block in _app_views_orders_edit_html_haml__3037086238800668844_70246830429400'
  haml (4.0.5) lib/haml/helpers/action_view_mods.rb:137:in `block (2 levels) in form_for_with_haml'
  haml (4.0.5) lib/haml/helpers.rb:278:in `with_tabs'
  haml (4.0.5) lib/haml/helpers/action_view_mods.rb:137:in `block in form_for_with_haml'
  actionview (4.1.0.rc1) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
  actionview (4.1.0.rc1) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
  haml (4.0.5) lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
  actionview (4.1.0.rc1) lib/action_view/helpers/capture_helper.rb:38:in `capture'
  haml (4.0.5) lib/haml/helpers/action_view_mods.rb:52:in `capture_with_haml'
  actionview (4.1.0.rc1) lib/action_view/helpers/form_helper.rb:434:in `form_for'
   () Users/paul/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/foundation_rails_helper-03f1be5eb06c/lib/foundation_rails_helper/action_view_extension.rb:9:in `form_for_with_foundation'
  haml (4.0.5) lib/haml/helpers/action_view_mods.rb:139:in `form_for_with_haml'
  haml (4.0.5) lib/haml/helpers/action_view_xss_mods.rb:28:in `form_for_with_haml_xss'
  app/views/orders/edit.html.haml:1:in `_app_views_orders_edit_html_haml__3037086238800668844_70246830429400'
  actionview (4.1.0.rc1) lib/action_view/template.rb:144:in `block in render'
  activesupport (4.1.0.rc1) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.0.rc1) lib/action_view/template.rb:338:in `instrument'
  actionview (4.1.0.rc1) lib/action_view/template.rb:142:in `render'
  actionview (4.1.0.rc1) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
  actionview (4.1.0.rc1) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.0.rc1) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionview (4.1.0.rc1) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
  actionview (4.1.0.rc1) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
  actionview (4.1.0.rc1) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
  actionview (4.1.0.rc1) lib/action_view/renderer/template_renderer.rb:17:in `render'
  actionview (4.1.0.rc1) lib/action_view/renderer/renderer.rb:42:in `render_template'
  actionview (4.1.0.rc1) lib/action_view/renderer/renderer.rb:23:in `render'
  actionview (4.1.0.rc1) lib/action_view/rendering.rb:99:in `_render_template'
  actionpack (4.1.0.rc1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
  actionview (4.1.0.rc1) lib/action_view/rendering.rb:82:in `render_to_body'
  actionpack (4.1.0.rc1) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
  actionpack (4.1.0.rc1) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
  actionpack (4.1.0.rc1) lib/abstract_controller/rendering.rb:25:in `render'
  actionpack (4.1.0.rc1) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (4.1.0.rc1) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
  activesupport (4.1.0.rc1) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /Users/paul/.rbenv/versions/2.1.1/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
  activesupport (4.1.0.rc1) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (4.1.0.rc1) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
  actionpack (4.1.0.rc1) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
  activerecord (4.1.0.rc1) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
  actionpack (4.1.0.rc1) lib/action_controller/metal/instrumentation.rb:40:in `render'
  actionpack (4.1.0.rc1) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  actionpack (4.1.0.rc1) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
  actionpack (4.1.0.rc1) lib/abstract_controller/base.rb:189:in `process_action'
  actionpack (4.1.0.rc1) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.1.0.rc1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:113:in `call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:229:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:229:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:86:in `run_callbacks'
  actionpack (4.1.0.rc1) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.1.0.rc1) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.1.0.rc1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  activesupport (4.1.0.rc1) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications.rb:159:in `instrument'
  actionpack (4.1.0.rc1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.1.0.rc1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.1.0.rc1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.1.0.rc1) lib/abstract_controller/base.rb:136:in `process'
  actionview (4.1.0.rc1) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.1.0.rc1) lib/action_controller/metal.rb:195:in `dispatch'
  actionpack (4.1.0.rc1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.1.0.rc1) lib/action_controller/metal.rb:231:in `block in action'
  actionpack (4.1.0.rc1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
  actionpack (4.1.0.rc1) lib/action_dispatch/routing/route_set.rb:48:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/journey/router.rb:71:in `block in call'
  actionpack (4.1.0.rc1) lib/action_dispatch/journey/router.rb:59:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/routing/route_set.rb:676:in `call'
  dragonfly (1.0.3) lib/dragonfly/middleware.rb:14:in `call'
  bullet (4.8.0) lib/bullet/rack.rb:12:in `call'
  newrelic_rpm (3.7.3.204) lib/new_relic/rack/error_collector.rb:55:in `call'
  newrelic_rpm (3.7.3.204) lib/new_relic/rack/agent_hooks.rb:32:in `call'
  newrelic_rpm (3.7.3.204) lib/new_relic/rack/browser_monitoring.rb:27:in `call'
  newrelic_rpm (3.7.3.204) lib/new_relic/rack/developer_mode.rb:45:in `call'
  rack (1.5.2) lib/rack/etag.rb:23:in `call'
  rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
  rack (1.5.2) lib/rack/head.rb:11:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/flash.rb:254:in `call'
  rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/cookies.rb:551:in `call'
  activerecord (4.1.0.rc1) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.1.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
  activerecord (4.1.0.rc1) lib/active_record/migration.rb:380:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:82:in `run_callbacks'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  airbrake (3.1.16) lib/airbrake/rails/middleware.rb:13:in `call'
  better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.0.rc1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.0.rc1) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.0.rc1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.0.rc1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.0.rc1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.0.rc1) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.1.0.rc1) lib/active_support/cache/strategy/local_cache.rb:87:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  dragonfly (1.0.3) lib/dragonfly/cookie_monster.rb:9:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/static.rb:64:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  airbrake (3.1.16) lib/airbrake/user_informer.rb:16:in `_call'
  airbrake (3.1.16) lib/airbrake/user_informer.rb:12:in `call'
  railties (4.1.0.rc1) lib/rails/engine.rb:515:in `call'
  railties (4.1.0.rc1) lib/rails/application.rb:142:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
  /Users/paul/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
  /Users/paul/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
  /Users/paul/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

Specs fail in Rails 4

I'm having trouble getting any of the specs to pass. It looks like most of them fail due to a 'model_name' method missing:

  1. FoundationRailsHelper::FormHelper errors generator should display errors
    Failure/Error: form_for(@author) do |builder|
    NoMethodError:
    undefined method model_name' for Author:Class # ./lib/foundation_rails_helper/action_view_extension.rb:8:inform_for_with_foundation'
    # ./spec/foundation_rails_helper/form_builder_spec.rb:174:in `block (3 levels) in <top (required)>'

I think including ActiveModel::Naming would include this method, but I'm not sure. The FoundationRailsSpecHelper module includes it IF it exists, but it doesn't seem to be included by default. Any ideas on how to fix this?

Overriding the field_error_proc

Globally overwriting the field_error_proc can cause issues if multiple form builders are used in the same app.

A potential solution is to use a similar technique that is used in https://github.com/plataformatec/simple_form, specifically here..

https://github.com/plataformatec/simple_form/blob/48cab46ca4d26236b446d870f5d25cd27e4b4701/lib/simple_form.rb#L175-L178

and here...

https://github.com/plataformatec/simple_form/blob/c3a307cb9501208e053f771738e34a3d93d33858/lib/simple_form/action_view_extensions/form_helper.rb#L41-L49

which only changes the field_error_proc within the custom form builder.

Cut a new gem?

0.4 Looks like it's nearly a year old now, and some very useful features have been added since then (e.g. support for more form tags). Any chance of a new version any time soon?

Cheers :)

hint produces an unwanted attribute

= f.password_field :current_password, required: true, hint: 'We need your current password to confirm your changes.'

Produces:

<label for="user_current_password" class="">Current password</label><input type="password" hint="We need your current password to confirm your changes." required="required"><span class="hint">We need your current password to confirm your changes.</span>

As you can see there's an unwanted hintattribute on the input.

I think the expected behavior is only to produce the span element.

Add ability to add prefix and postfix

Foundation gives you a number of options to add prefix and postfix to your form inputs with a <span>

It would be nice if that functionality transferred over to the form helper through an option.

Error in production mode

Hello. I am getting an error in the log when in production mode.

<module:ApplicationHelper>': uninitialized constant ApplicationHelper::FoundationRailsHelper (NameError)

At first I thought it was because I am using 0.3.alpha, then I switched to 0.2.1 and the issue still remains. Everything works fine when in development mode. If anyone has any ideas, please let me know.

Failing spec with Rails 5

After installing Rails 5 and freshly installing this gem, the following spec fails:

1) FoundationRailsHelper::FormHelper input generators should generate datetime_field input
     Failure/Error: expect(node).to have_css('input[type="datetime"][name="author[forty_two]"]')
       expected #has_css?("input[type=\"datetime\"][name=\"author[forty_two]\"]") to return true, got false

It's failing because the type is now datetime-local (see below). This has been introduced in Rails 5
(Old behaviour was to set type as datetime)

Here's what the capybara node looks like:

?> a = node.find('input')
=> <Capybara::Node::Simple tag="input" path="/html/body/input">

?> a.native
=> #(Element:0x3ff2ad56bf14 {
  name = "input",
  attributes = [
    #(Attr:0x3ff2ad7d94b8 { name = "value", value = "2011-06-18T20:30:00" }),
    #(Attr:0x3ff2ad7d94a4 { name = "type", value = "datetime-local" }),
    #(Attr:0x3ff2ad7d9490 { name = "name", value = "author[forty_two]" }),
    #(Attr:0x3ff2ad7d947c { name = "id", value = "author_forty_two" })]
  })

alias_method_chain is deprecated

DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from module:FormHelper at /Users/dsandstrom/Projects/einstein_video5/vendor/bundle/ruby/2.3.0/bundler/gems/foundation_rails_helper-646bd8477bf6/lib/foundation_rails_helper/action_view_extension.rb:19)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from module:FormHelper at /Users/dsandstrom/Projects/einstein_video5/vendor/bundle/ruby/2.3.0/bundler/gems/foundation_rails_helper-646bd8477bf6/lib/foundation_rails_helper/action_view_extension.rb:20)

Radio Button Helper Renders Value in Label

<%= f.radio_button :import_method, 0 %>

Renders:

<input type="radio" value="0" checked="checked" name="shop[import_method]" id="shop_import_method_0">
<label class="" for="shop_import_method_0">0</label>

Feature Request - Add initializer for gem settings.

I would like to be able to change the button default class for each app. I'm sure not everyone wants there buttons to have classes "small radius". Also, there are people who want there buttons to have class "success" (#43).

So I propose, an initializer gets added and settings for things like the default button class.

errors on select box

I'm using Safari 6.0.2. I have an error on a select box. Placement of the select box is off, making the error text slightly cut off.

Anyone else experience this issue?

Errors for file field

First, I'd like to say thank you for this awesome gem.

When there is an error for f.file_field, the error field has abnormal placement. I am using safari 6.0.1. Any way to rectify this?

Support rails 5

Please add support for rails 5:

   foundation_rails_helper was resolved to 1.1.0, which depends on
      actionpack (~> 4.1)

Thanks !

Consider gem version bump?

https://rubygems.org/gems/foundation_rails_helper

Versions
0.2.1 January 15, 2012
0.2 January 15, 2012
0.1.alpha January 14, 2012

Happy new year! There has been some great bug fixes since gem version 0.2.1, which released almost a year ago. I currently am bundling this gem directly from this github repo. However, I think it would be time to do a version bump for everyone pulling from rubygems.org. :)

Also, the images displayed in the readme are no longer available.

Once again, thank you for the wonderful gem and all your hard work!

Keil

Flash Helper keys are incorrect

I'm not sure if the flash helper keys are incorrect, or just outdated.

https://github.com/sgruhier/foundation_rails_helper/blob/master/lib/foundation_rails_helper/flash_helper.rb

    KEY_MATCHING = {
      :notice  => :success,
      :info    => :warning,
      :failure => :error,
      :alert   => :error,
    }

http://foundation.zurb.com/docs/elements.php
There are 4 types of alert boxes in foundation:

<div class="alert-box [success alert secondary]">
  This is an alert box.
  <a href="" class="close">&times;</a>
</div>

Maybe tomorrow if I have time I'll try to push a fix to this repo for it. I have never done a pull request before.

Rails doesn't write the html for show flash message

When I create a producto instance, my html is like show below:

<p id="notice">Producto was successfully created.</p>

They no have the class and attributes...

<div class="alert-box [success alert secondary]">
    This is an alert box.
    <a href="" class="close">&times;</a>
</div>

My ApplicationHelper:

module ApplicationHelper
  include FoundationRailsHelper::FlashHelper
end

If manually add this code, I can see the flash message:

<div class="row flash">
    <div class="twelve columns">
      <%= display_flash_messages %>
    </div>
</div>

Can you help me?
Thank you

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.