haml

Helper “fields_for” not working

懵懂的女人 提交于 2019-12-10 04:35:42
问题 I'm using nested attributes, but the fields aren't loaded in my view. Someone know what I missing? Rails 3.1, Ruby 1.9.2 Model 1: class Traditions::Material < ActiveRecord::Base has_one :material_asset, :dependent => :destroy validates_presence_of :title accepts_nested_attributes_for :material_asset end Model 2: class Traditions::MaterialAsset < ActiveRecord::Base belongs_to :material has_attached_file :asset validates_attachment_presence :asset end View (HAML): = form_for @material, :html =>

Error 'incompatible character encodings: ASCII-8BIT and UTF-8' due to 8-bit encoding of cookies (Rails 3 and Ruby 1.9)

我与影子孤独终老i 提交于 2019-12-10 03:56:35
问题 I moved a web app that was using 1.8.7 to 1.9.2 and now I keep getting incompatible character encodings: ASCII-8BIT and UTF-8 I have the database encoding to UTF-8 and I have also 'config.encoding = "utf-8"'. I saw some ideas as possible workarounds and I added Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 But it didn't work either. One specific chunk of code where I am getting this error is %ul.address - @user.address.split(',').each do |line| %li=

Performance implications of using :coffescript filter inside HAML templates?

别等时光非礼了梦想. 提交于 2019-12-10 02:08:27
问题 So HAML 4 includes a coffeescript filter, which allows us coffee-loving rails people to do neat things like this: - word = "Awesome." :coffeescript $ -> alert "No semicolons! #{word}" My question: For the end user, is this slower than using the equivalent :javascript filter? Does using the coffeescript filter mean the coffeescript will be compiled to javascript on every page load (which would obviously be a performance disaster), or does this only happen once when the application is started?

render a partial from jquery and haml

霸气de小男生 提交于 2019-12-09 12:22:44
问题 The functionality I plan on doing is to insert some form elements depending on a number chosen from a select tag. I have a select tag called for number_of_passengers, and i plan to dynamically append new passenger fields for the number chosen. Say I select 2 from number_of_passengers, then 2 forms should appear in a fieldset. these forms contain name, age weight etc. I tried following this: call a rails function from jquery? and just converted it to haml-speak but I get errors whenever I use

br tag not closing in Haml on Rails 3

瘦欲@ 提交于 2019-12-08 15:56:04
问题 I am having a problem getting Haml to close br tags. I have tried the following with no luck: %br %br/ I expect this to result in <br /> , but it always outputs as <br> , even with the slash character on the end. I have also tried adding the following options to application.rb (and I tried environment.rb) Haml::Template.options[:autoclose] = ['meta', 'img', 'link', 'br', 'hr', 'input', 'area', 'param', 'col', 'base'] Am I missing something? I though Haml was supposed to autoclose these tags

Haml -Illegal nesting: nesting within plain text is illegal

一曲冷凌霜 提交于 2019-12-08 15:48:49
问题 I am facing a weird error in my code while using HAML where my code is working on my Local Machine but when I am deploying it I am getting the following error ActionView::Template::Error (Illegal nesting: nesting within plain text is illegal.): My code looks like this %td{ :style => 'width:10px' } = link_to('Dashboard', dashboard_admin_clients_account_path(client)) if client.is_member? = link_to('Edit', edit_admin_clients_account_path(client)) - if client.removed_at.nil? = link_to('Delete',

Pass a variable to sass from programming language (coldfusion or PHP)

爷,独闯天下 提交于 2019-12-08 13:46:42
问题 I would like to pass a variable to my sass from coldfusion or php. Above I declare a var that I need to pass to sass to set a container-size in my _base.sass. Is there a way to do it? 回答1: Use the !default flag in your variable to do this. here's what i mean // SCSS file @import "php-variables"; // have php write this file first before compiling @import "variables"; // custom colors, font-sizes, etc. // contents of php-variables $myvar: #f00; // the value you're setting with php // contents

How do I work with checkboxes with DataMapper and Sinatra?

≡放荡痞女 提交于 2019-12-08 13:29:36
问题 I'm trying to make a simple room management service. The rooms have these properties: class Room include DataMapper::Resource validates_is_unique :number property :id, Serial property :number, Integer property :guest, String property :status, Enum[ :free, :occupied ], :default => :free end Then I create a new room like this post '/new' do content_type :json @room = Room.new :guest => params[:guest], :number => params[:number], :status => params[:status] if @room.save { :number => @room.number

How do I use Haml in a view in my new plugin?

纵饮孤独 提交于 2019-12-08 13:09:25
问题 I'm creating a new plugin for a jruby on rails application that will eventually be turned into a gem. Inside my plugin I have controllers, helpers and views. For my views I'd like to use Haml. The problem is that I can't seem to get it to recognize that they are haml templates. Is it even possible to do this? Is there a way for a plugin to have Haml as a dependency for its view? And by that I mean, I intend for the plugin that I'm creating to have a view created by the plugin, that can be

Select/Deselect All dynamic checkboxes in Rails 4 with Javascript

故事扮演 提交于 2019-12-08 11:08:29
问题 I have followed this StackOverflow Question's Answer1 and Answer2 but not getting result.. As I am calling all checkbox list's data from Range tabel. and their id is also defined by data.. Let me show you the code for this screenshot = f.collection_check_boxes :range_ids, Range.active, :id, :name, {},:class=>'checkbox' which returns as <input id="campaign_range_ids_1" class="checkbox" type="checkbox" value="1" name="campaign[range_ids][]"> <input id="campaign_range_ids_2" class="checkbox"