helpers

How do I use the `--helper` flag in a rails 3 controller generator?

半城伤御伤魂 提交于 2020-01-03 08:48:12
问题 The documentation from rails generate controller says: [--helper] # Indicates when to generate helper # Default: true Now, it doesn't specify how to indicate a value. So, since the default is true, that means that excluding it won't indicate false, because… true is the default. So it must either be --helper=false or --helper false , but I tried both, and they both resulted in error false [not found] The good news is that it did not generate a helper, because it was confused, so I still got

Rails: Refactoring HTML producing helper method to use a partial - how to use blocks there?

こ雲淡風輕ζ 提交于 2020-01-03 05:28:30
问题 After my earlier question Developing helper functions that generate HTML: should I rather use nested content_tag()s or partials? I am convinced now to rewrite some of my more complex HTML generating helper functions to use templates instead of nested content_tag() calls. So here's my original helper: def bootstrap_navlist(&block) classes = ['nav', 'nav-list'] content_tag(:ul, class: classes.join(' ')) do capture(self, &block) end end And that's what I came up with using a partial now: def

Rails/RSpec - writing tests for original helper methods

筅森魡賤 提交于 2020-01-03 02:36:05
问题 I'm on the chapter 5 exercises for Michael Hartl's Rails Tutorial and am trying to wrap my head around how Rails/Rspec is testing a helper method full_title in app/helpers/application_helper.rb . All of my tests are in spec/requests/static_pages_spec.rb and within them, I'm calling full_title to cut down on code bloat. So, in order to test the original full_title I create a test in spec/helpers/application_helpers_spec.rb and include it via spec/support/utilities.rb . The code is passing, but

Are there any view helpers to generate CSS?

谁说胖子不能爱 提交于 2020-01-01 14:23:14
问题 I like the idea of HTML helpers, which allows me not to write all the HTML for common elements, while still gives me full control, preserves model-view separation and can be strongly typed. I'm wondering if it is possible to generate CSS stylesheets or style definitions the same way - using helpers in view markup? Ideally, I would like to have some of the CSS generated based on some object-oriented rules and definitions. I can't find any solutions that will offer anything more than stylesheet

Change default Rails text_area helper rows/cols

て烟熏妆下的殇ゞ 提交于 2020-01-01 12:13:15
问题 I am finding myself specifying :rows => 5 on all my text_area form helpers, So I looked up its definition and found the DEFAULT_TEXT_AREA_OPTIONS to be the hash dictating these options. However, the hash has this freeze method on it and I looked it up, it means it can't be changed. If you could recommend me some options to try to do a app-wide :rows => 5 for all text area, I'd really appreciate it. Thanks 回答1: You can do: Write own helper: def readable_text_area(form, method, options = {})

Switch word positions on Notepad++

别来无恙 提交于 2019-12-25 16:54:51
问题 Hello guys I need a bit help I neeed to switch words position on notepad++ they are like this. Grands|Albz So I wanna to switch grand with albz to to other side without moving | to make it like this Albz|Grands Whloe of the text any help please? 回答1: do 1) cntrl+f 2) go to the replace tab 3) type Grands|Albz in find what: 4) type Albz|Grands in Replace with: 5) Click on Replace All box(3rd from the top in right side in the pane) to replace all the occurrence. If you want to make it generalize

Meteor / Blaze rendering : {{each}} in another {{each}} doesn't return the right data (data context)

◇◆丶佛笑我妖孽 提交于 2019-12-24 17:50:02
问题 I was wondering if you could give me some clue how to tackle this 'problem'. I'm a newbie in JS (+ Meteor), so it might be super simple for you. I'm working with helpers and blaze/spacebars for rendering. I have a simple helper: Template.monitoring.helpers({ 'realtime': function(){ return { house: house.find( {} ), neighbours: neighbours.find( {} ), } } // end of realtime }); // end of helpers At this point, everything is OK. I'm able to retrieve the data I want. The problem is that I'm not

EmberJs: render template inside Handlebars-helper

巧了我就是萌 提交于 2019-12-24 08:57:53
问题 I have this situation in which I have the template-name stored in a variable. I noticed that if you have for example var config = { view: "PeopleView", .... } ; that you can't do {{view App[config.view]}} If this is possible, I'm still interested in the solution! Anyway, I decided to fix this with a Handlebars helper: {{setVariableView config}} ... Ember.Handlebars.registerBoundHelper('setVariableView', function(value, options) { return App[value.view].create(value) ; // <-- this doesn't work

How do I set a time in a time_select view helper?

和自甴很熟 提交于 2019-12-24 08:49:49
问题 I have a time_select in which I am trying to set a time value as follows; <%= f.time_select :start_time, :value => (@invoice.start_time ? @invoice.start_time : Time.now) %> This always produces a time selector with the current time rather than the value for @invoice.start_time. @invoice.start_time is in fact a datetime object but this is passed to the time selector just fine if I use <%= f.time_select :start_time %> I guess what I'm really asking is how to use the :value option with the time

What am I doing wrong with this rspec helper test?

拥有回忆 提交于 2019-12-23 19:49:38
问题 All I'm trying to do is spec how a one line helper method for a view should behave, but I'm not sure what kind of mock object, (if any) I should be creating if I'm working in Rails. Here's the code for events_helper.rb: module EventsHelper def filter_check_button_path params[:filter].blank? ? '/images/buttons/bt_search_for_events.gif' : '/images/buttons/bt_refine_this_search.gif' end end And here's my spec code, in events_helper_spec.rb: require File.expand_path(File.dirname(__FILE__) + '/..