Displaying 20 results from an estimated 1000 matches similar to: "Monkey patching a gem (rails_admin, with Rails 3)"
2006 May 05
1
class_eval in ROR''s attribure_accessor.rb
hi,
here is a snippet code in ROR''s attribure_accessor.rb. the usage of
class_eval is different with "class_eval(string, <, file, <line>>)"
somewhat,
i don''t understand this usage, who can explain it more detail to me?
def cattr_writer(*syms)
syms.flatten.each do |sym|
class_eval(<<-EOS, __FILE__, __LINE__)
unless defined?
2008 Nov 19
3
Mock today
In some of my unit tests, I find the need to set today to a different
value than the actual today. For example, to test the model method
"balance_of_today", which takes no argument, I want to have Date.today
be a specific date for the purpose of testing. In other words, I want
to do something like this:
mock_today(Date.new(2008, 2, 1)) do
... test code...
end
My implementation for
2006 Apr 12
3
noob question
Hi *,
I am writing my first app based on the ''depot'' application but with some
suttle differences to help me learn.
I am a bit sutck with following and would be grateful for any help:
I have the following controller:
class MainController < ApplicationController
def index
@objects = Object.certified_items
end
end
This relates to a field called
2005 Dec 29
3
Why do plugins use class_eval?
I''m writing my own plugin and all the plugins I''ve seen use class_eval in the
method that is called in the including module. For example:
http://wiki.rubyonrails.com/rails/pages/HowToWriteAnActsAsFoxPlugin
module Foo
module Acts #:nodoc:
module Fox #:nodoc:
def self.included(base)
base.extend(ClassMethods)
end
# declare the class level
2011 Jul 18
0
rails_admin & carrierwave
Hi to all.... Please help me =(
I use rails_admin and I need to upload files with the help of it.
I found carrierwave for it and installed it with the help of
https://gist.github.com/884835. But It doesn''t work =( when i login in
rails_admit? i see default text field instead field for choose a file,
but this text field without CSS styles of rails_admin. I think, that my
views, which i
2013 Sep 19
0
problem with change Model url for rails_admin
i wont to change url name of model in rails_admin
example i have model Help and
*url : /admin/help/ *
now i wont to change name of url to
*"/admin/customerHelp"*
so how can it be posible to change in rails_admin.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving
2013 Oct 07
0
rails_admin problem in raoutes, parallel login area in devise
hello friends,
i am using rails_admin as webapp admin interface. it create a User model by
default using Devise gem. after that i am creating another authorization
area member. now /admin route change to /member/sign_in from user/sign_in.
any body have idea how to create a parallel login area in devise with
rails_admin.
/admin => /user/sign_in (default)
after
* rails g devise member*.
it
2006 Jul 16
1
Helpers for partials too ?
MainController implies main.rhtml, which will automatically have access
to the methods inside MainHelper (in \app\helpers\main_helper.rb).
Should not the partial templates called from main.rhtml via <%= render
:partial => ''partial'' %> also have access to the methods in main_helper
?
I have tried
<% display_dates = create_display_dates(@events) %>
and
<%
2006 Jun 18
2
Why can''t I use a session? (Symbol as array index)
Hi All
I can''t for the life of me see what is wrong with this. Maybe it''s cause
it''s midnight...
I want to put some data in a session and I have some code like this:
class ApplicationController < ActionController::Base
model :mything
def ApplicationController.chosen_thing
session[:chosen_thing] ||= MyThing.defaultThing
end
end
So whenever I try to
2007 Sep 10
2
Removing an AR class definition, for testing plugins
I''m writing an acts_as_* plugin and am trying to BDD it. Ideally my
specs would look like:
describe ActsAsCloneable, " basic cloning" do
load_example_classes
School.class_eval do
acts_as_cloneable
end
before(:each) do
@old_school = School.create! :name => "Baylake Pines", :city =>
"Virginia Beach", :guid => "abc123"
2006 Apr 25
7
Rails producing the / page.
Hi all
Very simple question, im sure, but I cant find docs anywhere that tell
me how to do this.
What I want is for the index page of the server to be generated from
rails, is www.wibble.com/ will result in a page that has been processed
by rails, has the templates etc.
>From what I can see, the index page comes from public/index.html How do
I get this to be a rails page?
Thanks
Jonathan
2006 Sep 04
2
"include" versus "extend" - what's the difference
Hi,
Just wondering when one would use "include" over "extend"? Both seem to
bring in methods to the class no?
The context is I''m just trying to understand why both are used with the
acts_as_audited plugin:
Full extract from plugin (used within here):
==================================================
# Copyright (c) 2006 Brandon Keepers
#
# Permission is hereby
2005 Dec 14
1
just installed rails on ubuntu, error creating rails dir -->unexpected token: ''#<RubyToken::TkLPAREN:
Hello there good rails people!
Just did a fresh install of rails on my new (old) Ubuntu machine. I am
running ruby 1.8.2 and have installed about five extra packages that do
not come with Ubuntu. I managed to install ruby-gems and used gems to
successfully install rails but I am getting an error message when I run
rails, it seems to be choking on a Tkl paren. Google has not turned up
much
2012 Jan 04
1
render :update problem with IE 9
Hi,
I have a legacy web site based on ruby on rails 3.0.9 which works just fine
with Firefox, chrome and IE 8, but I receive an HTTP 406 error every time
when I check the web site with Internet Explorer 9. I narrowed down the
problem to the respond_to + format.js + render :update trio, but I did not
manage to solve the problem until now.
I created a small example for reproduction:
The action
2006 Jul 24
1
Injecting actions into controllers
Hi,
I''m trying to write a plugin that should inject an action into the controller.
Please note, not just an instance method, but also an _action_, one of those
that are listable by running ControllerClassName.action_methods.
I wrote the following code:
def render_field_search(name, object, controller, options = {})
controller.class.class_eval do
2010 Aug 10
2
undefined method `has_many' for Object:Class +Savage Beast 2.3 plugin
Hi, i am using Savage Beast 2.3 plugin for the forum and i got and
error
undefined method `has_many'' for Object:Class
C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb:
9:in `included''
C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb:
7:in `class_eval''
C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb:
7:in
2006 Jul 26
4
Execute code when an inheritance happens, or disabling STI
I am trying to inherit from a ActiveRecord class defined in a plugin.
The problem is that ActiveRecord thinks I am doing an STI and is looking
up a table that doesn''t exist.
Currently, I have a method in the parent class that looks like this:
def self.fix_table_name
class_eval do
set_table_name(Inflector.tableize(self.to_s))
end
end
The problem is that this method
2008 Mar 04
9
What is your workflow? Or how to use the story runner the right way.
I really would like to know how people are using the Story and Example
runner to write their software.It would be great to get some direction on
it, because I think I''m missing some points.
Taking the outside-in approach in thought:
At first we write a high-level customer-facing story, this story fails.
Then we start using mocks at object level to use them as a design tool,
and so we
2009 Feb 02
2
ActiveRecord::AssociationTypeMismatch (User(#54754560) expected, got User(#54510280))
i keep getting this AssociationTypeMismatch error. i think this could
be a bug related to ruby/rails when using mixins. heres a short
version of my code:
# user.rb
require ''friend_invitation''
require ''friendship''
class User < ActiveRecord::Base
include FriendInvitationUser, FriendshipUser
...
end
# friendship.rb
...
module FriendshipUser
def
2006 Jun 26
5
How can I dynamiclly generate models?
I am trying to write a plugin, ''acts_as_commentable'', for my models -
Image, Book, Music and so on, I do not want to use polymorphic
association, so very model should have its own comment class.
Here is my code
acts_as_commentable.rb
module Commentable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def