Hassan Schroeder wrote in post #1074840:
> On Wed, Sep 5, 2012 at 1:00 PM, Sa S. wrote:
>> Well that's kind of what I need help with, I'm not sure where it needs
>> to be defined in a many-to-many relationship. I've already created the
>> join table that cont
Well that's kind of what I need help with, I'm not sure where it needs
to be defined in a many-to-many relationship. I've already created the
join table that contains both ids.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Grou
Okay great, thanks! I think I'll actually trying doing this in the join
table. I guess my last question would be how would I call that method
from that join table in let's say the Player show view?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscrib
Thanks for the help! Although I'm not sure I totally understand it,
still a bit of a noob. So if I wanted to do something as simple as
subtract the user's handicap from the course's handicap, how would I
create a method for that in the Player model? (sorry maybe you might
have done it already b
Hi Michael,
Thanks for the reply.
I actually have created the join table as documented in the rails
guides, with the right naming convention and all. It's got a model_1_id
and a model_2_id, and an index
Sure, I can give some more details. I'm creating a golf application that
let's users enter
I'm working on a Rails application having a REST API in JSON format and
versioned (according to this excellent Ryan's cast:
http://railscasts.com/episodes/350-rest-api-versioning).
For instance, there is a spec/requests spec:
require 'spec_helper'
describe "My Friends" do
describe "GET /
Hello all. I am trying to see how much of my code is covered by Cucumber
features/scenarios. The feature steps are actually using the
browser/views to tests, so they are not directly instantiating
controllers, etc.
My question is, is there a way using SimpleCov or any other coverage
tool to give m
Hi,
I have the same SMTP settings. I'm just sending emails to myself to test
out. I do the see the sent mail in the console. But I don't receive any
email.
The SMTP settings was working with Rails 2.3.8.
Any ideas?
Thanks!
--
Posted via http://www.ruby-forum.com/.
--
You received this messa
Yes Marnen, I agree; it's not really useful. But I prefer to do this
rather then having a table with only 1 row. That's why I would like to
get a singleton model with a static data (and always the same id for
associations with other models).
--
Posted via http://www.ruby-forum.com/.
--
You r
yong gu wrote in post #957495:
> If you are using rails 3, see this
> http://railscasts.com/episodes/219-active-model
Thanks! But there is a problem with ActiveModel: I can not make
associations such as belongs_to or has_many...
--
Posted via http://www.ruby-forum.com/.
--
You received this m
Hello,
I would like to create a simple ActiveRecord model, but working without
table... Is that possible? I think we can this a virtual model.
And I would like to be able to use relations (like has_many :users, etc)
with this model (named App for instance), such as:
> App.first.users
Thanks f
Many thanks for your help. Very appreciated.
Happy RoR3 developments!
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To
Hello,
I have this kind of relation:
class Article < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :article
attr_protected :article_id
end
The default scenario inside controllers looks like:
@article = Article.create(:title => "fo
Mickael Gerard wrote:
>
> render :nothing => true, :status => whatever
>
> And you have a short cut method for "only headers"
> response ActionController::Base#head
> usage :
>
> format.xml { head :forbidden }
>
> Mickael
You solved my question. Many thanks.
--
Posted via http://www.ruby-for
Hello all,
I am working on Rails 3, and I would like to return a forbidden error
message from a controller.
I had trying something like that:
def my_action
respond_to do |format|
format.html { redirect_to(login_path, :warning =>
I18n.t('.forbidden'), :status => :forbidden) }
format.xml
FWIW: I just discovered that if I uninstall the 0.7.0 version of the
win232-service gem
and install this one instead:
gem install -v=0.5.2 win32-service
I can now install mongrel services w/o error.
On Nov 23, 11:59 am, SA wrote:
> I think I am seeing the same issue. See also versions
I think I am seeing the same issue. See also versions of various gems.
This used to work with the 0.3.4 version of the mongrel_service gem.
Is there a fix or update for this. I want to avoid hacking line 115 /
ruby/lib/ruby/gems/1.8/gems/mongrel_service-0.1/lib/mongrel_service/
init.rb if possible.
Gustav Paul wrote:
> That shouldn't need any modification to your routes. Unless you have a
> very
> peculiar setup, files from your ./public/ directory are automatically
> served
> as static.
>
> RAILS_ROOT/public/files/some_file.pdf
>
> Should be accessible as:
>
> http://myapp.com/files/s
Hi -
I want to enable access to a directory inside my app's public folder.
This means that when a user will navigate to http://myapp.com/files, he
will actually be accessing the root of RAILS_ROOT/public/files. This
folder will contain static files, and doesn't really need any
controller/actions
quot;, but the Album "funk" is saved anyway.
usuario_test.rb
... def test_new() assert Usuario.new; end ...
Colin Law wrote:
> 2009/6/15 Le Sa :
> I am not sure from your reply whether you still have a problem, if you
> do then the problem may be a syntax error in one of you
Thanks Fred!
I didn't understand why it inserts an album because an Usuario can or
can not have an Album. :/
Frederick Cheung wrote:
>>
>> � 1) Error:
>> test_dois(UsuarioTest):
>> ActiveRecord::StatementInvalid: Mysql::Error: Field 'usuario_id' doesn't
>> have a
>> default value: INSERT INTO
actually, if it is the same database, then there is no way to happen at
the same time, right?
I don't know, maybe something like this:
class Tablet < ActiveRecord::Base
validate :must_have_in_stock
def must_have_in_stock
qnt = Tablet.find(product_id).quantity
erros.add(:quantity,
Nik Kumar wrote:
> Can anyone please give the steps(commands) how to connect ruby on rails
> to MySQl in fedora8.
>
> I have installed MySQL and Ruby in my system.
>
> Please specify any further installations to be done
>
> Reply will be appreciated.
http://www.google.com/search?q=rails+mysql
Hello!
here is my unit test:
require 'test_helper'
class UsuarioTest < ActiveSupport::TestCase
# Replace this with your real tests.
#test "the truth" do
#assert true
#end
def test_salvar
usuario = Usuario.new
assert usuario.save
end
def test_dois
assert true
end
It seems the problem stemmed from the session_expiry check:
> for automatical timeout and removal put the following in your
> application controller:
> # session-timeout after inactivity of one hour.
> MAX_SESSION_PERIOD = 1800
>
> before_filter :session_expiry #<-- this was the probl
> just to make sure: you are using active_record_store now, right?
Yeah.
> try to delete your browser's cookies and cache as well as your session
> table. maybe you have a conflict with one of the old sessions/cookies.
Deleted all cookies, cache and authenticated sessions (in firefox -
Ctrl+S
Right, sorry. Thought it might deserve a seperate thread. Here's the
other post if someone wondered here looking for an answer:
http://www.ruby-forum.com/topic/179690#786710
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this messag
sa 125 wrote:
> I added login to my app and storing the sessions in the db. I
> un-commented the "config.action_controller.session_store =
> :active_record_store" line in the environment.rb file, and the :secret
> in the application.rb file.
>
> Now, when I
I added login to my app and storing the sessions in the db. I
un-commented the "config.action_controller.session_store =
:active_record_store" line in the environment.rb file, and the :secret
in the application.rb file.
Now, when I try to login I get the error InvalidAuthenticityToken.
Here's my
MaD wrote:
> for your permissions problem I'd suggest the implementation of roles
> or groups. that way you can add users to groups or give them roles,
> which can be checked in a before_filter in your controllers.
I thought about creating groups, but then won't this complicate things?
I'll have
I read that rails 2.3 will handle nested models seamlessly with
accepts_nested_attributes_for inside the parent model
(http://guides.rubyonrails.org/2_3_release_notes.html).
Any idea when the final 2.3 is going to be released (currently in RC1)?
--
Posted via http://www.ruby-forum.com/.
--~--
Hi -
I am using a fairly standard authentication in my app (user model,
before_filter in application_controller). This authentication is taken
almost entirely from the 3rd ed. of the agile web dev w/ rails. A few
questions about all that -
1. I'm still in dev environment, but I noticed that I'm
Hi - I'm trying to figure out how to group nested fields in the form
such that they all submit with a certain order. I followed the complex
forms railscast (http://railscasts.com/episodes/75), but I'm trying to
submit a nested model with more than a single field.
<% fields_for 'project[task_attri
my bad. I moved that block to the bottom of the environment.rb file,
after the "end" of the Rails::Initializer code, but got this error:
NoMethodError (undefined method 'validates_positivity_of' for
#)
/../active_record/base.rb:1833:in 'method missing'
I tried loading this method though ./s
Hi - I want to add my own validation to a rails app, and need help
making it global to my app. Basically, the validation makes sure a
number is positive - I found this code on the at
http://snippets.dzone.com/posts/show/822:
module CustomValidations
def validates_positive_or_zero(*attr_names)
> Do you edit one by one, or are you looking for something more like an
> edit in place within the listing?
>
It's more like finding the records to update using a filtering form, and
then updating some or all the attributes in these records using another
update form. More code and explanatio
Thanks for the quick response.
I'm not sure I follow. My view is rendered with partials, called from
search function when the user submits the search:
<%= render :partial => 'record', :collection => @search_results %>
--
def search_records
# get the search form results from params
conds =
One of my views enables searching records using a text field. The
rendered view contains only records that match the search.
After the view has rendered, I want to add an option to perform an
update on the displayed records. The problem is, I don't know how to
figure out which records are shown,
I used link_to_remote with the :submit option pointing to the parent of
the input I want to submit (doesn't have to be a form!).
<% form_for ... do |f| %>
<%= collection_select ... %>
<%= link_to_remote... :submit => 'inside_form' %>
# rest of form fields
<% end %>
Hope this he
I've decided on a different approach and I could use some help:
The page containing the records to modify also contains a small form to
filter the displayed records. It uses observe_form to periodically call
a function to filter the view.
I want to use this form filter as a selector on which r
I have a form for a model, that has an auto-fill button based on
existing record. Basically you can choose if to duplicate an existing
record using a select list of the record already in the db.
This select list is inside the form for the new model, but I need to
somehow submit it in an independe
Thanks, this is just what I wanted.
> a subselect like this is usually better written as a join (which is
> probably what the db does behind the scenes ie
> SELECT products.* from products
> inner join locations on locations.id = location_id
> where address like '%foo%'
>
> which will be produce
I want to be able to change a property on multiple records in my app. I
thought about adding a checkbox so that one can pick which records to
update. The question is how to implement the actual update - if the
checkbox isn't part of the model, how can I iterate the records in the
view and see whic
I'm trying to use the :conditions option on the activerecord find. For a
simple query such as "SELECT * FROM products WHERE name LIKE
'%#{name}%'" it's obviously
:conditions => ["name LIKE ?", "'%#{name}%'"]
However, I have associated models, so for example I might have
product.location.address
I am using jQuery with the rails defaults in my app and would like to
call jQuery commands from my RJS templates or from respond_to blocks.
I've seen this used in a railscast:
page << "jQuery('some_id').css('color','red');"
but I'd like it to execute with the others, namely:
page.visual_effect
I read DHH's post on using various js libraries with rails, and thought
I'd give it a try with jQuery (http://loudthinking.com/posts/32).
What I have is a page composed of various partials, and I'm trying to
invoke jQuery to render a different partial when something is clicked
on.
What I can't f
Yup, no "self" needed since it's an instance method:
class Product < ActiveRecord::Base
def stocked?
self.in_stock ? 'yes' : 'no'
end
end
works great - thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because
I would like to write a few custom methods for my model, but keep
getting an error saying the method is not defined for the model (playing
in the console).
For example, I have a product model, and I want a method called stocked?
that will return 'yes' or 'no' depending on an in_stock boolean fiel
After cleaning my vendor/plugins directory from in_place_editing which,
apparently, was conflicting with super_in_place_controls, everything
worked well.
Remember to keep in_place_edit_for inside the controller:
class ProductsController < ApplicationController
in_place_edit_for :product, :n
Anyone successfully used super_in_place_controls
(http://os.flvorful.com/super_in_place_controls/download)?
I've tried to add them to my project, but whenever I update something it
sets the css display property of the element to none. When I refresh the
page it the text appears again but it doesn
Mukund wrote:
> form_for results in a POST operation. You are checking for
> request.xhr? in your controller to render the partial. Use
> remote_form_for instead to get a XHR request.
>
> Pressing an enter key in a text field doesn't submit a form. The tags
> don't add that in.
>
> Regards,
I need a way to replace a table row with a form to edit it's values --
kind of like edit-in-place, only that I need a custom form (check boxes,
select lists, text fields, etc). My table is generated with a partial of
a model.
The row should have a button/link to enable to go in and out of edit
mo
Hey all -
What I'm trying to accomplish is creating my own edit in place on a set
of data. Right now I'm just toying with some nonsense app, but when I
figure it out it'll be put to good use. I divide my code between the
view, the partial, the controller and the rjs template. For the sake of
exam
Hi - trying to update a table with page.replace_html using a partial:
The view (index.html.erb):
[code=]
<%= render :partial => 'product' %>
[/code]
The partial (_product.html.erb)
[code=]
<% for product in @products %>
<%= product.name %>
<%= product.vendor.name %>
<% end %>
[/code]
Th
How would I reset the controls on a form? I have a few text fields and
selection lists, and I want them cleared (text fields) or restored to
the top value (the :prompt in the select). I tried the code below with
render :update.
the form is in the view:
<% form_for :item, :html => { :id => 'items
Using and developing exclusively for firefox -- one of the benefits of
building a site that'll only be run in an office intranet :)
I'll give those a try - thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because
right.. thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubs
I'm trying to create an editable table by rendering a partial containing
a form.
In the index:
<%= render :partial => 'product_edit', :collection => @products %>
In the partial:
<% form_for :product do |f| %>
<%= f.text_field :name %>
<%= f.select :in_stock, [['YES','true'],['NO','
Hi - I have the following problem: my app has a form that acts as a
filter to a table on the page, so that the user can search any value in
the table (via text box) or use select lists for more specific search.
The form is being observed by an observe_form helper that runs every 1-2
seconds or so.
I thought so, just wanted to confirm. Thanks!
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t
How would I go about installing rails plugins offline? I cannot connect
to the web on my work computer, though I have a dedicated internet
machine for downloads and such.
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this mes
Hi - I'm trying to enable dynamic filtering of a table in my app, using
selection lists and a search box. Here's the basic layout of the table:
# ---
# in app/views/products/index.html.erb
<%= select :product,
:vendor_id,
Vendor.find(:all, :order => '
On the same note, how would I go about turning the column headers to
links that'll sort the table by the column clicked? Such that if the
user click the Product Name header, the table sorts alphabetically by
product name.
Thanks again.
--
Posted via http://www.ruby-forum.com/.
--~--~
Hello - In my app I'm displaying many data grids, and I'm trying to add
multiple selection lists and a search box to each grid to allow
filtering the rows. Since I'm very new to this, I'm trying to understand
how to do things right from the start. Say I have product and vendor
models like so:
./s
You were right, I had validates_presence_of :name, :vendor_id, :in_stock
inside my model. Once I removed it I was able to save false values. How
can I still validate a boolean once I allow a user to enter values (even
though it'll be either one or the other, using a checkbox or something)?
--
I'm trying to create a model that uses a boolean type, supported by
mysql engine. My generate is like so:
./script/generate model Product name:string vendor_id:integer
in_stock:boolean
However, when I try to play with the console and save products to the
database, only products defined with in_s
> in the view (app/views/people/index.html.erb):
>
> <% content_for :title do -%>
> Listing People
> <% end -%>
>
>
>
> First Name
> Last Name
>
> <%= render :partial => "people", :collection => @people %>
>
> in the partial (app/views/people/_people.html.erb):
>
> >
> <%
These were all really helpful -- I really appreciate the depth of the
responses. I now only have a problem with using a collection in
rendering a partial. I think I followed the exact rules, but here is
what I did anyway:
The layout (app/views/layouts/application.html.erb):
...
<%= yield :t
Those were really helpful posts -- I think I got the general idea, in
which I should specify in the controller which layout it should belong
to, and then in the layout file use <%= yield %> to render these views.
I'll keep playing with it and see what comes up.
Thanks!
--
Posted via http://w
Hello - very new to rails and MVC, I'm trying to figure out how
layouts/partials co-exist. My basic layout (application.html.erb) looks
like this:
<%= render :partial => "main/header" %>
<%= render => :partial => "main/menu" %>
<%= render => :partial => @partial %>
Thanks - I'll look into your suggestions, though it might take me a
while to come up with something. When I do, I'll repost to this thread.
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
Hello,
Being a new transfer to rails from ASP.NET, I'm looking for some help on
how to approach an old problem with RoR. I build and maintain my
company's internal data site. We deal with finances, and thus I have
pages to display data grids of clients, products, accounts and all that.
These gri
72 matches
Mail list logo