Displaying 20 results from an estimated 110 matches similar to: "using modules with models?"
2007 Jan 17
1
include ClassMethods in plugins
Why is that in so many plugins I see people using (including
acts_as_taggable by DHH):
# init.rb
ActiveRecord::Base.send(:include, ActiveRecord::Acts::SomeModule)
# lib/some_module.rb
module ActiveRecord
module Acts
module SomeModule
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def acts_as_something
# code
2006 Feb 14
1
Error handling
Hi,
I''m stuck right now with a problem concerning error handling. I''ll try to
explain the problem in short:
In a controller class I have a method edit:
def edit
@some_class = SomeClass.find(params[:id])
end
The record originates from a database table. What happens if the user enters
a field that fails validation and I return to my edit page? I get the idea
that th
2012 Nov 23
3
how to query yaml file with hiera function.
Hi guys,
i have a hiera.yaml config file like this:
---
:hierarchy:
- %{env}/%{tmp_module_name}
- %{env}/%{tmp_module_name}.common
:backends:
- yaml
:yaml:
:datadir: ''/etc/puppet/hieradata''
I also have a test/some_module.yaml file like this:
---
db:
root : pass
port : ''3306''
I am also using the hiera function
2006 Apr 10
3
autocomplete 2nd field based on 1st field''s input
I''m trying to populate a field named "file_name" based on the input of a
field named "title". So, for instance, based on the following input in
the "title" field:
My Title Is Awesome
I would want the following "file_name" to be autocompeted on the fly:
My_Title_Is_Awesome
I''ve been going over all the autocomplete examples out there,
2005 Nov 21
3
New code: proposed release?
So I just wanted to review what most of my new code does for those
who are not familiar with it yet.
======
The biggest feature of my work is the docbook export. This means that
any valid textile markup can be exported to the docbook standard. I
added a new chapter tag to go along with the export.
ch. 1. Here is the title
In HTML, this will produce:
<h1>1. Here is the
2007 Apr 30
7
Migrating spec_helper with modifications
Hello,
After moving into the HEAD of rspec, I am greeted with a mountain of errors,
which I expected, due to my specs not being migrated.
I use hpricot for a lot of my view tests, as it is extremely simple to
traverse the DOM with it. I used to include HpricotSpecHelper in
spec_helper.rb, like so:
require ''hpricot_spec_helper''
module Spec
module Rails
module Runner
2015 Oct 27
3
Add a mapping to a C++ lambda
Apologies for the noop question in advance (just getting started with
LLVM), and I'm not entirely sure if this is the right list to post to. is
it?
I have some lambda functions as member variables that I want to have my
LLVM language make calls to. I've added a mapping to them, but this doesn't
seem to enable LLVM to resolve the functions. I asked on stackoverflow but
the suggestion
2007 Nov 13
6
Groups
Hello,
Is it possible to group many nodes together? Suppose I have a large
number of machines that I all want to have the same config - rather
than specify them as individual nodes each inheriting the same config,
I''d like to say that a group inherits a config, and define the group
elsewhere.
Does this sort of construction already exist? Could it be cobbled
together from what we
2011 Sep 01
7
couldn't find file 'jquery' rails 3.1 stable mountable engine
When I create a new engine in Rails 3.1 stable and then access the dummy
app or the engine I get an error say that the app can''t find jquery.
I''ve created the engine using
rails plugin new coffee --mountable
I''ve also created a basic controller in the engine and the dummy app. If
I remove the javascript include tag, everything works. But with the tag
there it just
2009 Jul 17
2
Rsnapshot/rsync buffer overflow
I have been using rsnapshot on OS X for a bit now to backup my debian home
server to my external HD but have now started getting this error.
Shiny:rsync-3.0.6 kurt$ sudo rsnapshot sync
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \
--exclude=mtab --exclude=core --rsh="/usr/bin/ssh -i \
/Users/kurt/.ssh/id_rsa" root at home.thisisnotajoke.com:/home \
2012 Dec 17
20
early clean exit from module?
Hi folks,
I''ve poked around the language reference, and havent found anything on this
so far. I''d like to be able to force a clean early exit from a module.
WITHOUT encasing the whole body of the module in an if statement.
What I''m looking for:
class somemodule {
#no this isnt going to be a global variable I''m just using that as an
example,
if
2013 May 13
2
Creating defined resources based on array of parameters.
Hi all,
With the goal of making my code a little more DRY, I am trying to define
resource parameters in an array of hashes, and then create defined
resources from these array items. I am having trouble figuring out the
syntax for accessing the hash values for the hash currently being worked on
("self?").
Here''s the code to make it clear:
##### Configuration arguments
2010 May 12
2
How to add an after_save callback on runtime on a particular instance
class User < AR
end
user = User.new
Let''s say that I have a user instance with me. After this record is
saved I want an after_save callback which would print the id of the
record.
The only catch is that I am not allowed to change the User class. How
can I accomplish my goal? Is that even possible to add an after_save
callback on a particular instance object. Any metaprogramming
2012 Oct 18
0
unexpected return (LocalJumpError) only when executing this code within autoloaded classes?
Posted on stackoverflow but no traction yet:
http://stackoverflow.com/questions/12942505/why-does-using-set-trace-func-work-in-some-places-but-cause-unexpected-return-l
The following is a generified part of the code in a gem I''m working on:
module SomeModule
class << self
attr_accessor :procedure
def log_events(*args)
args.flatten!
2004 Jan 23
2
[Bug 712] ssh does not properly utilize OS specified authentication methods on AIX
http://bugzilla.mindrot.org/show_bug.cgi?id=712
dtucker at zip.com.au changed:
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |793
nThis| |
Status|NEW |ASSIGNED
------- Additional
2007 Jan 25
10
Problems with building a complete kernel
I have a plain vanilla Centos source (not 100% sure where we got it
from), but I can't seem to get a build that installs correctly.
I tried the method described at
http://wiki.centos.org/HowTos/Custom_Kernel, but rpm doesn't like the
output file, and even if I install it with -F, nothing seems to happen -
no new kernel, now initrd, nothing.
When I tried following the directions in the
2007 Feb 09
12
Module Organization
This is in reference to David Schmitt''s writeup [1]
I like that writeup a lot; I just had a few comments/clarifications:
* Namespaces: For now, we just use a flat namespace for modules, i.e.
you can''t have modules within modules, and you always know that in a
fully qualified name ''foo::bar::baz'' that ''foo'' is the module name and
2013 Jan 15
3
Multiple class calls via dashboard
Hi,
I currently have puppet setup and backed into the dashboard and using ENC.
I wish to control as much of the configuration of machines via the
dashboard.
However, I have a requirement to call a module/class multiple times and was
wondering if this is possible? in a normal manifest I''d do this with the
following:
node "somenode" {
somemodule::submodule {
2006 Sep 13
0
Fwd: Systemtap vs Dtrace web page corrections.
Hi
Here is System tap''s representives response to my comments and mine
back to that list. Since it was on a public mailing list i''m reposting
here, since there is obvious interest.
James Dickens
uadmin.blogspot.com
---------- Forwarded message ----------
From: James Dickens <jamesd.wi at gmail.com>
Date: Sep 13, 2006 1:51 PM
Subject: Re: Systemtap vs Dtrace web page
2011 Jun 16
0
Rails 3.1, SASS, @import, and directories
So, here''s the problem: @import isn''t liking other directories.
Example:
app/
assets/
stylesheets/
extras/
_mixins.sass
_variables.sass
photographs/
index.css.sass
And the contents of app/assets/stylesheets/photographs/index.css.sass is:
@import "../extras/mixins", "../extras/variables"
I get the following