haml

Make a fields_for block conditional

≯℡__Kan透↙ 提交于 2020-01-16 20:01:11
问题 I have a User Model and an Instructor Model. There is a one-to-one relationship between user and instructor. And some users will be instructors and some will not. As such I have a registration form that uses a fields_for method to write to both. How can I write to the instructor table only on the condition that they say they are an instructor, such as through a checkbox. And when they do write I want to maintain my validations of the table along with the rest of the form Ideally this would

Make a fields_for block conditional

烈酒焚心 提交于 2020-01-16 20:01:10
问题 I have a User Model and an Instructor Model. There is a one-to-one relationship between user and instructor. And some users will be instructors and some will not. As such I have a registration form that uses a fields_for method to write to both. How can I write to the instructor table only on the condition that they say they are an instructor, such as through a checkbox. And when they do write I want to maintain my validations of the table along with the rest of the form Ideally this would

detecting the current_page? in navigation partial dont work

喜夏-厌秋 提交于 2020-01-15 09:44:33
问题 This is the code of 'shared/subnav' partial. When i click on a link it shows error No route matches {:action=>"show", :controller=>"location"} but routes are defined. i think there is some problem in below code. -if current_page? location_path = link_to 'Edit Location', edit_location_path -if current_page? user_path = link_to 'Edit User', edit_user_path -if current_page? alert_path = link_to 'Edit Alert', edit_alert_path Here are my routes location GET /locations/:id(.:format) locations#show

Rails / Bootstrap / HAML - How to convert this code to display flash messages to HAML?

岁酱吖の 提交于 2020-01-15 06:54:17
问题 I want to convert the following code to HAML to handle Bootstrap's alert messages in a Rails 4.2.2 application. I've tried manually, using html2haml and online converters and the code I get never works. The code: <div class="alert <%= case type.to_sym when :alert, :danger, :error, :validation_errors 'alert-danger' when :warning, :todo 'alert-warning' when :notice, :success 'alert-success' else 'alert-info' end %> alert-dismissible" role="alert"> <button type="button" class="close" data

undefined method `render' for class `ActionView::Base'

随声附和 提交于 2020-01-15 03:57:06
问题 When I start the application crashes following error /home/stereodenis/.rvm/gems/ruby-1.9.3-p194@nyanya/gems/haml-3.1.6/lib/haml/helpers/action_view_mods.rb:15:in `alias_method': undefined method `render' for class `ActionView::Base' (NameError) What maybe wrong? full trace https://gist.github.com/5e3244d488068c9d0ba7 回答1: If you are using a render inside a helper you have to include the functionality! include AbstractController::Rendering Hope it helps 来源: https://stackoverflow.com/questions

Auto-removing all newlines from Haml output

对着背影说爱祢 提交于 2020-01-14 13:09:30
问题 I'm using Haml in a Rails 3 app, and its newlines drive me nuts! For example, %span foo renders as <span> foo </span> But I'd much rather want <span>foo</foo> The reason (apart from being cleaner XML) is that extra newlines are a problem for my Selenium tests because they mess up the ability to do XPath queries like "//span[.='foo']" . So I'd have to write '\nfoo\n' instead (ew!), or use //span[contains(text(), 'foo')] , which matches too broadly. I know I could use the alligator operators ("

How to solve has an integrity attribute issue on bootstrap.min.css

断了今生、忘了曾经 提交于 2020-01-14 07:21:13
问题 I am using bootstrap icons in my project which gives me error Subresource Integrity: The resource 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' has an integrity attribute, but the resource requires the request to be CORS enabled to check the integrity, and it is not. The resource has been blocked because the integrity cannot be enforced. Can any one help me to solve this issue and when we move to production the icon is not loaded. So I am using below link for

How to solve has an integrity attribute issue on bootstrap.min.css

亡梦爱人 提交于 2020-01-14 07:21:09
问题 I am using bootstrap icons in my project which gives me error Subresource Integrity: The resource 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' has an integrity attribute, but the resource requires the request to be CORS enabled to check the integrity, and it is not. The resource has been blocked because the integrity cannot be enforced. Can any one help me to solve this issue and when we move to production the icon is not loaded. So I am using below link for

content_for vs yield in partials

好久不见. 提交于 2020-01-10 14:16:19
问题 In rails 3.0 with HAML (3.1.4) I have some template-like partial , like _template.html.haml: .panel.top = yield :panel_top .content = yield some another partial which will be displayed using prev template (all this stuff is rendered using AJAX, but this doesn't matter) - content_for :panel_top do .title.left = title content text and this worked like a charm in Rails 3.0 But, after upgrade to 3.2 this fails! Yiels just yields "content text", so I have "content text" twice and no title at all

Dependency error while installing the gem “joyride-rails”

◇◆丶佛笑我妖孽 提交于 2020-01-07 07:51:17
问题 My rails version is 3.2.12 . I am trying to implement gem "joyride-rails", "~> 0.0.14" in my application, but it clashes with some of my other gems. Already in my Gemfile: gem "haml-rails", ">= 0.4" gem 'activeadmin-mongoid', github: 'elia/activeadmin-mongoid', branch: 'active-admin-spec-suite' When I run the bundle command, I get this error: Bundler could not find compatible versions for gem "haml": In Gemfile: joyride-rails (~> 0.0.14) ruby depends on haml (~> 3.1) ruby haml-rails (>= 0.4)