haml

Wordpress with Haml/Sass

别等时光非礼了梦想. 提交于 2019-12-23 07:08:37
问题 Having used Haml and Sass for a few Rails side projects, I've found that they speed up my frontend development tremendously. However, I haven't found a Rails blogging platform that's as robust or familiar to clients as Wordpress, so that's still generally my go-to for projects that require a light website with basic CMS / blogging functionality. (I've looked into Radiant, Mephisto, etc, and while I certainly appreciate suggestions of Rails blog engines, that's not really the question I'm

Rails button_to No route matches {:action=>“complete”, :controller=>“dashboard”, :name=>“Order”}

喜欢而已 提交于 2019-12-23 03:57:13
问题 Please help i have tried my best. I really need your help. So im trying to make a mark order as complete. Now it all works up to the button to mark order as complete. I ran a migration to add. class AddCompleteToOrder < ActiveRecord::Migration def change add_column :orders, :complete, :boolean, default: false end end Then i added a method the order.rb of def complete! update(complete: true) end Then routes.rb resources :orders do post "complete", to: "orders#complete", on: :member end Then

Rails button_to No route matches {:action=>“complete”, :controller=>“dashboard”, :name=>“Order”}

拈花ヽ惹草 提交于 2019-12-23 03:57:07
问题 Please help i have tried my best. I really need your help. So im trying to make a mark order as complete. Now it all works up to the button to mark order as complete. I ran a migration to add. class AddCompleteToOrder < ActiveRecord::Migration def change add_column :orders, :complete, :boolean, default: false end end Then i added a method the order.rb of def complete! update(complete: true) end Then routes.rb resources :orders do post "complete", to: "orders#complete", on: :member end Then

Difference between 'for' and 'each' Iterators on Ruby on Rails [duplicate]

感情迁移 提交于 2019-12-23 01:04:05
问题 This question already has answers here : “for” vs “each” in Ruby (9 answers) Closed 3 years ago . I have some doubts about the diference beetwen 'for' and 'each' Iterators on Ruby on rails. I have this case, how is the best practice for this? Def(method) present in the application_helper.rb file: def milestone_icons icons = ["", "icon-world", "icon-star-twohdd-o", "icon-users", "icon-notification", "icon-clock", "icon-eye", "icon-like-filled", "icon-credit-card", "icon-bell" ] end Select

Neat way to conditionally test whether to add a class in HAML template [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-22 05:17:15
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Append class if condition is true in Haml (with Rails) I'm using a template that allows you to mark a list item as current (using class=current ), highlighting it in a nav bar. In HAML, this looks like: %li.current Menu item A %li Menu item B %li Menu item C I have this code in a Sinatra view and want to programmatically add the class=current , depending on a parameter to the view. How do I do this in the

Unescaping HAML in an Attribute Hash

烂漫一生 提交于 2019-12-22 04:38:23
问题 I have a problem similar to some I've found on stackoverflow, but not quite the same. I'd like to avoid the solution to the following question: https://stackoverflow.com/a/10407782/996587 Basically, would like the following HTML output: <div class='myclass' extraattr='UNESCAPED <>& CONTENT'> Content... </div> The HAML I'm using looks like this: .myclass{ "extraattr" => "UNESCAPED <>& CONTENT" } Content... I can't quite figure out how to get the content to output the way I want. Tried applying

What's the right syntax to use Rails `content_for` helper in a HAML context

非 Y 不嫁゛ 提交于 2019-12-22 04:01:19
问题 What are the differences in the use of - and = in the following: - content_for :header do %h1 Title and = content_for :header do %h1 Title What is the right way? 回答1: That depends on what you want to do. To render the header right away, do: = content_for :header do %h1 Title To store the content and use it later, do: - content_for :header do %h1 Title And to use it somewhere in your view(s): = content_for :header In Rails < 3.2 you needed to use = yield :header . That is still supported in

Can you interpolate ruby variables within HAML css?

倾然丶 夕夏残阳落幕 提交于 2019-12-22 03:48:07
问题 I need a series of classes, .module1, .module2, ... module(n). I also want to define those classes using css, ruby and HAML: :css .mod1 { background-image: url("#{extra.image}"); } Is it possible to interpolate ruby variables to save work? .module.mod"#{extra.id}" %h3 #{extra.title} %p #{extra.description} %a.btn-default{:href => "#", :target => "_top"} enter now :css .mod#{extra.id} { background-image: url("#{extra.image}"); } 回答1: According to the HAML_REFERENCE I used this method: - flavor

Partials in Coffee HAML (.hamlc)

放肆的年华 提交于 2019-12-20 18:34:36
问题 I am using backbone.js on a rails backend with HAML Coffee , which is compiled by haml_coffee_assets. There is some duplication in my templates. Is there a way to create rails-like partials to dry up my templates? Addition: Can I do content_for(:something) in Coffee HAML? 回答1: There is no content_for helper in Haml Coffee, but you simply can render another template within a template. Without Local Variables For example, you've a template test : %p My Partial %ul %li Is included You can

how to run ruby in haml in javascript definition?

风格不统一 提交于 2019-12-20 18:29:45
问题 how can I run ruby code inside javascript in haml? if I use var = #{message} in my example I get undefined local variable or method message when I move - message = 'it works' above :javascript everything works fine I want to run iteration .each inside :javascript . See the last code sample for what I need in final javascript code. Where I need to loop few ruby variables (or one hash of hashes of hashes?) to get this. Data (='basics') can have few elemenets. It can have children with few