Displaying 20 results from an estimated 10000 matches similar to: "how do I bypass using the standard layout for a file"
2005 Dec 16
3
sharing layout code among different controllers
I want to have one layout for my whole application. The app
has multiple controllers. Is it true that layouts are associated
w/ one controller?
thanks, etienne
--
Posted via http://www.ruby-forum.com/.
2009 May 13
2
Object and Classes ?
I found a tutorial for creating classes using generic functions ? S3
way ! It was short description so I couldn't grok in full its
usage ... So far so good, what i currently do is something like this :
Blah <- function(data,...) UseMethod('Blah')
Blah.default <- function( ...... ) {
self = ....
class(self) <- 'Blah'
self
}
Blah.some_method <-
2006 Feb 15
2
extending rails via /lib - problems
I wanted to group some functions which I use in some models in one
place. Controllers have application.rb and views have helpers but I
couldn''t find anything about models. Using the /lib directory seemed to
be the only way.
Alright... so I have something like this:
/lib/code.rb
class ActiveRecord::Base
def method_a(n)
.......
end
def method_b(n)
........
end
end
2006 Jul 12
1
When to use Mutex::synchronize?
I have a simple question when to the synchronize method in the Mutex
class.
Now that backgroundrb has allow_concurrency = true there is no need
to synchronize database calls in threads.
The question I have is lets say I have a simple method in my worker
as follows:
def some_method
SomeModel.find_all each do |obj|
obj.some_count += 1
obj.save!
end
end
It accesses the database, but
2006 Feb 18
5
Model methods and partial view templates
I have a method in a controller that invokes a
render :partial => ''some_partial_view''
In that view, I''m trying to access a method defined in a model, like
this;
<% for view in @an_array %>
<% local_var = view.some_method() %>
<% another_var = view.a_column_name %>
etc..
I am getting an undefined method error but the model is accessible
2006 Feb 16
10
Ruby class variables and access from view templates
I have an app that requires me to define a class variable (actually an
array) in a controller and then access it from within a view. It seems
that the class variables aren''t working right. Here is an example of
what I''m trying to do.
class DisplayController < ApplicationController
@@thumbnail_array = Array.new
...
def some_method
@@thumbnail_array = SomeModel.find_all
2006 May 21
3
Where to put partials called from the application layout
Hello,
My main application layout, app/views/layout/application.rhtml looks
like this:
something
render partial_1
something else
render partial_2
something else
render partial_3
The partials are not really doing anything, i use them to keep the
layout modular (i.e . to have ~30 lines instead of 200). Now, the
question is where to put _partial_1.rhtml, _partial_2.rhtml,
_partial_3.rhtml.
If i am
2006 Apr 14
5
state_models plugin and file_column?
I was looking at Kyle Mawell''s extremely nifty-looking StateModels
plugin
http://www.kylemaxwell.com/articles/2006/02/06/fun-with-single-table-inheritance
and before I go down the road with it, I was wondering if anyone has
used it with file_column.
The way file_column deals with an uploaded file -- by storing it to the
filesystem in a path that employs the model name and id --
2008 Jan 27
2
conditional validation
Hi,
How can I validate user info under certain conditions? For example, I
just downloaded a plug-in that allows me to validate phone numbers,
but what I would like is to only validate the phone number if it is
not blank and if the user_type_id field is equal to one.
How can I achieve such a validation in my user model?
Thanks, - Dave
--~--~---------~--~----~------------~-------~--~----~
You
2006 Jul 22
3
How to use variables in your layout views?
Let''s say I wanted to find 3 products from my database and put them
in the layouts/application.rhtml view. Where do I find these 3
products? Do I just do it in application.rhtml?
<% for product in Product.find(:all, :limit => 3) %>
Because I was under the impression that you really don''t want to do
this in your views. You should do this in your controllers and
2009 Apr 21
2
validates_uniqueness_of
hello all,
i am new to RoR programming and am struck with the functional test whole
checking for uniqeness of carriers. If it is not unique,the the bin
shudn''t be created.Can someone help me in correcting my code.
def test_create_failure_cycle_unique
begin
num_bins = Bin.count
post :create, {:bin => { :carrier => carriers(:A), :cycle =>
cycles(:one), :name =>
2010 Sep 16
3
Resyful authenticatio current_user in model
Hi,
I am using Restful authentication for user authentication.
I want the current logged in user object in my model property.rb
Problem is current_user is not working on model.
How can I fix this I need that?
Please help me out.
Thanks,
Mike
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk"
2007 Jun 18
2
weakness of helper?
Hi ,
It comes to me that helper has some weaknesses:
1) It is hard to test . No easy way to write test code for it.
(or Just i didn''t know?)
2) Not easy to reuse it on other controller/view/model.
it looks like to that putting the helper code into a model (a
fully helper model , or a mixed model) is good practice.
However i agree that some html intensive
2012 Sep 04
5
Associations and Math between Models
I''ve setup two models, 1 and 2, that are associated by
has_and_belongs_to_many. I''m trying to get an attribute from model_1 to use
in a method in model_2. When I use the code below, I get an error saying
''undefined method model_1_id''. What am I missing? Thanks!
Model_2.rb
Class Model_2 < ActiveRecord::Base
...
has_and_belongs_to_many :model_1
def
2006 Jul 25
3
Question about how Mongrel process works with singletons
Hi,
I have a controller where I access a singleton class that I use to
connect to a DRbprocess
DrbConnector.instance.some_method
I notice that on every request, the constructor is called so it is
making a new instance of this singleton. Is this normal?
Thanks,
Curtis
2006 Jul 14
3
Accessing the Model class from Controller
Hi,
I wonder if there''s an easy way to access the associated Model class
from its Controller. Something that would allow me to write snippets
like the following:
class PeopleController < ApplicationController
def some_method
person_model_class =
self.some_method_to_retrieve_the_person_model_class()
end
end
Cheers,
Marco
--
Posted via
2006 Jan 17
9
Setting layout template in .rhtml
I''ve a single controller -
class ContentController < ApplicationController end
in the app/views/content folder I have quite a few .rhtml files
I need to be able to choose a different layout template to
use in each of these .rhtml files.
i''d like to be able to do something like (which doesn''t work..)
<% layout ''layout1'' %>
Any
2006 Mar 14
5
Best way to use partial rendering in global layout
I have a global layout in application.rhtml and I''d like to render a
partial template within it.
Currently, I have this:
<%= render (:partial => ''side_nav'') %>
but it seems to be looking in the controller specific view directory.
What is the best way to do handle controller - global partial rendering?
Wes
--
Posted via http://www.ruby-forum.com/.
2008 Aug 30
5
make layout false
Hi
i am having lot of HTML files those files dont want layouts so, for
each rhtml i am mentioning in controller list.rhtml,edit.rhtml
def list
render :layout=>false
end
def edit
render :layout=>false
end
is any simple method to mention wat are the files dont want layout in
one line..
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
2005 Dec 31
7
Application Errors w/ layout & custom view pages
1) I get Rails Application Error when trying to use layout
test_controller
def list
layout "stdlayout"
end
in the views/test/layouts stdlayout.rhtml
<html>
<head><title>test</title></head>
</body>
<h1>Test</h1>
<%= content_for_layout %>
</body>
</html>
2) I get Rails Application Error when trying to use a separate