You can use the as option on your form_for tag:
form_for(@person) will generate inputs like person[name]
form_for(@person, :as = something[person]) will generate an input like
something[session][email]
--
You received this message because you are subscribed to the Google Groups Ruby
on
Sorry, should have been something[person][name] instead of
something[session][email]
--
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 unsubscribe from this
If the button is to submit a form, you can use image_tag_submit
http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-image_submit_tag
Otherwise, you can just use link_to(image_tag(...))
--
You received this message because you are subscribed to the Google Groups
Check what the error message is telling you. You need to install a
JavaScript runtime.
Could not find a JavaScript runtime. See
https://github.com/sstephenson/execjs for a list of available runtimes
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails:
Check out the guide to associations. It should have more information than
you need...
http://guides.rubyonrails.org/association_basics.html
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
It's case sensitive. Are you sure you don't mean name instead of Name?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/mqTCBUktDAQJ.
To post to
The error message is telling you the problem:
relation appointments does not exist
Can you post the contents of your CreateAppointments migration file? I'm
assuming this is where the appointments table should be created.
--
You received this message because you are subscribed to the
id and class are built-in ruby methods that are present on all object
instances.
Rails uses them in a different manner than the default Ruby implementation.
They are undefined so that they can be picked up by the method_missingmethod.
--
You received this message because you are subscribed to
For your first example, Rails already has built-in keys for submit buttons
that you can change globally:
en:
helpers:
submit:
create: Create %{model}
update: Update %{model}
Or only for a specific model:
en:
helpers:
submit:
post:
create: Create the new
Just curious why you want to do this without using any database or models
or gems?
At any rate, check out this tutorial below. It uses a model, but you can
copy the code from the DataFile class to accomplish what you are trying to
do.
Your folder structure does not seem right. You should not have a home
folder. You should have a users folder with a home.html.erb
On Tuesday, April 17, 2012 10:06:30 AM UTC-4, amvis wrote:
i have one controller
*class UsersController ApplicationController*
* *
* def home*
*
Set config.assets.debug = false in config/development.rb
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/WDMIcYMtBJUJ.
To post to this group, send
What problem are you trying to solve by doing this?
Just seems like it would make your code more complicated with no real
benefit.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
no is a reserved word. You will need to enclose it in quotes.
NO: Nope
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/JsFPHGqMHHQJ.
To post to
Can you paste the exact error that you are getting?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/KQzCf8AuYtoJ.
To post to this group, send
I am a little confused here. If ModelB belongs to ModelA, I think your
foreign key relationship is backwards. The model_b_table should have a
foreign key to model_a_id, not the other way around.
Regardless, though, you can pass conditions to delete_all which should help
you accomplish what you
When you write belongs_to :parent Rails expects there to be a class
called Parent.
If you want this to be related to the MyModel class, you'll need to
explicitly state that:
belongs_to :parent, :class_name = 'MyModel'
--
You received this message because you are subscribed to the Google
Session variables should be shared, unless I'm not understanding the
question.
You can set a session variable in one controller like so:
session[:my_key] = 'my value'
Then access it in another controller by simply calling session[:my_key]
--
You received this message because you are
You can specify a layout that applies only to specific actions in a
controller:
layout whatever, :only = [ :some_action ]
Check out the guide on layouts for more options:
http://guides.rubyonrails.org/layouts_and_rendering.html
--
You received this message because you are subscribed to the
I believe those two are just the most common.
Look at the rest of the code, though. It looks like you can specify other
flash values like so:
redirect_to suppliers_path, :flash = { :success = 'Supplier was
successfully created.' }
--
You received this message because you are subscribed to
Your constraint is slightly wrong.
Unless you are settings request.session[:token] somewhere else in your
code, chances are it's going to be nil. What you most likely want to check
for is request.params[:token] which will match the token in the URL.
You also have it backwards. The constraint
For the simple reason that single quotes in Ruby do not allow for string
interpolation (such as \r and \n), while double quotes do.
On Tuesday, March 6, 2012 2:33:23 PM UTC-5, Craig White wrote:
.join(\r\n) did the trick. Needed to use double quotes and not single
quotes (don't understand
You probably want to use $(#allclick).update instead of
$(allclick).update
Note the # that indicates you are selecting an element by the ID.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
How do your Article and Blog models relate to the User model?
Assuming User has many Articles and Blogs you can simply do this:
user = User.find_by_whatever(something)
user.articles.tagged_with(tagname)
user.blogs.tagged_with(tagname)
--
You received this message because you are subscribed to
Well you have at least two options to hide the parameters:
You could change your link_to call and include :method=:post so it does
actually send a post request. This doesn't really hide the parameters since
the user can still view the source of the page and look at them.
You could send them as
Maybe just put the logic in the controller?
if @brand.nil?
if @store.nil?
@brand_link_path = from_catalog_path(params[:id].blank? ?
Category.root.id : params[:id], product.id, product.name_url)
else
@brand_link_path = from_store_path(@store.id, product.id)
end
else
Sounds like you could just add a belongs_to :user to the Comment class.
But since you already have comments on the user, you'll need to give the
reverse association another name. Perhaps comments_owned
So add has_many :comments_owned, :class_name = Comment to User.
--
You received this
I think your issue may be a mixup with class instance and instance
variables.
However, what's the issue you are having with all this? Are you getting any
error messages?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this
What exactly are you trying to do? All that search_field does is create a
HTML input with type=search
If you want a dropdown you should use collection_select or something similar
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view
Pretty sure that YES and NO are reserved words.
Try putting the definition in quotes:
NO: Norway
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
This is by no means a RoR question. But the solution is pretty simple, so
I'll give in.
One way to do it would be to just put next if line.lineno == 1 at the
beginning of the loop.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view
If you can do it in JavaScript, you can always just do window.history.go(-2)
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/84XQPpvPqsEJ.
To post
You have the developer/:user_name/delete route set to use delete as the
method, rather than get
Since browsers usually don't support sending requests other than post or
get, you'll need to pass a _method=delete parameter to that route
Check out the rails guide on routing for more information:
It depends how you generate the controller. If you use a command like this:
rails g controller posts index show edit new update create destroy
It will indeed create a GET route for each action. Kind of annoying.
You can generate the restful controller and route declaration by using the
Just a note that you should be careful using this method to increment a
value. It can cause a race condition.
A safer method is to use increment_counter since it updates the value
directly in the database, not using the current attribute value on the
instance
The problem is that the inner string is not marked as html_safe. In your
link_to tag, this string is not considered html_safe:
link_to(*rights.controller + raquo; + rights.action*, :controller
= rights, :action = edit, :id = rights.id)
Colin's suggestion, which is the solution, is to
Try this:
:include_blank = Please select
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/ysC9cdWs6J8J.
To post to this group, send email to
Try this. You can pass a string to include_blank
:include_blank = Please select
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/r-jglcjPF-IJ.
To
The :prompt option was not added until rails 3.1.0
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/cSLW0PgNtgcJ.
To post to this group, send email
What does your view look like? Do you have any error message related code
in there?
What does the output HTML look like? Is the error message repeated in the
HTML?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion
The easiest way is probably to just have a boolean is_admin field on the
user model.
Really depends on your other requirements though.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
How did all the children end up with the same ID?
Posting some of your problematic code can help us help you.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
If you don't want them to be compiled, you can just put them directly in
the public/assets folder instead of in app/assets
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
They are not compressed because you have config.assets.debug = true
Kind of strange though that they are in the wrong order. What does your
javascript_include_tag look like, and what do the files it's calling look
like?
--
You received this message because you are subscribed to the Google
I apologize... I guess I wasn't sure what you were asking.
ActionController::Base doesn't have *any* methods included. Not even the
index, new, edit, etc. The only methods available are the ones you add in
your application. So adding delete method to ActionController doesn't
really make sense.
You can easily add a delete method to your controller:
def delete
@post = Post.find(params[:id])
end
Then add it to your routes as well:
resources :posts do
get 'delete', :on = :member
end
And you're done
--
You received this message because you are subscribed to the Google Groups Ruby
You could just have your welcome#index action redirect to another
controller/action if the user is signed in.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
I've used both, but prefer kaminari.
I like kaminari's concept of scopes and using views rather than the method
will_paginate uses.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
report_listing_path will return the path to whatever route you have
defined as report_listing
You can run rake routes from the command line to see which routes you
have configured in your application.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails:
No rails necessary.
Check out the timeago jQuery plugin.
http://timeago.yarp.com/
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/Mr_ShXivZOUJ.
Did you restart rails on the production server after you updated the file?
The old version is probably being cached.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
So whenever you migrate down and back up it works? Sounds like the
migration is working properly then.
Under what circumstances does it not work?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
On Sunday, October 30, 2011 9:31:50 PM UTC-4, John Merlino wrote:
get send_activation_notification
= :send_activation_notification, :as = send_activation do
resources :users do
resources :accounts
end
end
But it doesn't work for me. Note that
Well provided you don't have any code in your application that won't work
with https, you should be good to go.
Just make sure the domain you are using to access your Rails application is
SSL protected (via Apache, load balancer, or other means) and then simply
access it using https.
--
You
What do you mean by comment? Commenting your code? In that case you can
just use a JavaScript comment:
// this is a comment
/*
this is also a comment
*/
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web
I think for Rails to recognize that the attribute should be included, you
need to use attr_accessible rather than the Ruby method attr_accessor.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
error.full_messages does indeed call human_attribute_name.
Did you check the source for that method in the link you posted?
http://ar.rubyonrails.org/classes/ActiveRecord/Errors.html#M000311
full_messages @base.class.human_attribute_name(attr) + + msg
--
You received this message because
On Friday, October 21, 2011 3:53:33 AM UTC-4, Ruby-Forum.com User wrote:
But there is something wrong.
Does someone can help me?
Probably. What is wrong? Are you getting any error messages? Have you
checked out what params looks like in your controller (puts params.inspect)?
--
You received
Have a look at the documentation for check_box_tag
http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-check_box_tag
It specifies that any other keys passed to options will be used as HTML
attributes. So you can pass your onclick attribute to check_box_tag in the
On Friday, October 21, 2011 2:57:56 PM UTC-4, Ruby-Forum.com User wrote:
Task: I want use postgresql sequence for generation of primary key.
I use 'set_sequence_name', but this don't work.
What part of it does not work? Are you getting any error messages?
--
You received
Well you don't exactly have to do it by *hand*. It's pretty easy to write a
script to generate the command for you. Just change table_name to whatever
your model is...
table_name = Post
output = [ rails g scaffold #{table_name} --skip-migration ]
ignore_columns = [ 'id', 'created_at',
I think what you're looking for is delegate which is a rails extension to
Module:
http://api.rubyonrails.org/classes/Module.html#method-i-delegate
class ModelC ActiveRecord::Base
has_many :model_a
end
class ModelA ActiveRecord::Base
belongs_to :model_c
delegate :version, :to = :model_c
I believe you can also pass a --skip-migration option to scaffold so it
won't generate the migration.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
Gotcha. You could always create a helper for it.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/HweoZagzy1cJ.
To post to this group, send email
How do you call the session_code method?
What data type are unit_id and code? And what does a typical session[:code]
look like?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
Why not just something like this? Then you can put your dojo.js in
assets/javascripts and compile it like normal. Seems kind of unnecessary to
add extra logic to javascript_include_tag
%= javascript_include_tag
http://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/dojo.xd.js; %
script
On Friday, October 14, 2011 2:53:20 AM UTC-4, Ruby-Forum.com User wrote:
I have one big problem: when I try record to db through
update_attributes! (which must save when record invalid).
I'm not so sure that's entirely accurate. Check out the API for
update_attributes! and save! methods:
You're defining @review as an instance variable, so you have to use it as
one in the view:
$(#votes).html(%= *@*review.votes_count %)
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
Now you have the opposite problem... You are now calling list as an instance
method and you have it defined as a class method.
You need to do ONE of the following.
Define it as a class method, and call it as a class method:
def self.list
code
end
@list = Sale.list
Define it as an instance
That's to be expected with your HTML.
What you currently have will generate HTML that looks like the following if
you have 3 reviews:
p id='votes'1 vote/p
p id='votes'2 votes/p
p id='votes'3 votes/p
$(#votes).html(3 votes)
$(#votes).html(4 votes)
$(#votes).html(5 votes)
See the problem?
The
Those are not warnings at all. Just normal log messages.
Your browser is requesting the js, css, and jpg files with a conditional
GET. The server is returning HTTP status code 304 since the file has not
been modified since the last time the browser accessed. This is just a log
of that
Let's say I have a controller with 2 collection actions for viewing tasks
(accessed by /tasks/active and tasks/complete respectively).
def active
@tasks = Task.all(:complete = false)
respond_with(@tasks)
end
def complete
@tasks = Task.all(:complete = true)
What does your User class look like? You might have something else in there
that's firing before save.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
You're using the syntax of serialize properly.
The problem looks like it's in the JSON.load method not properly handling a
nil value:
def load(source, proc = nil)
if source.respond_to? :to_str
source = source.to_str
elsif source.respond_to? :to_io
source = source.to_io.read
else
Seems like it would be a lot easier to just have the logic in the
controller.
Right now you have the logic in the routes, then you'll also need logic in
the controller to check whether params[:id] or params[:site_photo_id]
exists.
If you have just one route and move the logic to the
If he is using Rails 3.1 it's not necessary to manually include the jQuery
library using a script tag. It's also not necessary to manually include
application.js like he is doing.
It's better to use the asset pipeline.
Make sure your Gemfile contains the following line:
gem 'jquery-rails'
What does the value of your @employee variable look like. Where do you
assign it?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/m94o6iq5IUEJ.
What do you mean by How can .js files be 'required' in other .js files?
That's not really the way JavaScript works.
What exactly are you trying to do?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web
The :modified_strategy is just a symbol that tells the helper which method
to call on your object to get the name/value of the textarea.
If you want to manually change the value of the textarea, you can overwrite
the value attribute:
f.text_area(:modify_strategy , :value =
Most likely the location of the rails executable is not in your path.
What does your path variable look like?
echo $PATH
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
Technically I think it should still work but it's even easier in 3
match 'about', :to = 'info#about', :as = :about
match 'contact', :to = 'info#contact', :as = :contact
match 'privacy', :to = 'info#privacy', :as = :privacy
--
You received this message because you are subscribed to the Google
What data type is the position column in your database?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/aj7wLKhPGKgJ.
To post to this group, send
Something like this should do the trick. You can just add this as a helper.
def asset_url(source)
#{request.protocol}#{request.host}#{asset_path(source)}
end
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the
Can't you just add the status to the order clause?
:order = status asc, messages.created_at desc
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
I believe in MySQL and PostgreSQL you can do something like this:
order by status in (1,4,5,6,2,3,8,9,7) asc
Which would translate to something like this in Rails:
:order = status in (1,4,5,6,2,3,8,9,7) asc, messages.created_at desc
Not sure if that will work verbatim though. You might have to
That query is nothing to worry about. It's just rails running a query to
figure out which tables you have in your database so it can figure out which
columns they have so it can make your models work properly.
In production it should only run once (when the server is first started).
But then
Do you have a controller named ProductsController?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/sUuMsWHWdxoJ.
To post to this group, send email
It's Rails convention that controllers should use the plural name of the
model, like Product*s*Controller
You could probably make it work by using the singular name of the model, but
it would go against convention and wouldn't be very easy to maintain.
--
You received this message because you
You have the route specified to only accept POST requests, but by using
link_to, you're creating a hyperlink that generates a GET request.
You'll need to either change your routes to accept a GET request, or change
your method of calling the URL to a POST request (from a form).
--
You
Why are you storing the comment date in a separate table?
The code you had is pretty close. Assuming you have a posted_date on the
comments_date model, and the commends model has_one(:comments_date):
@comments.sort do |c|
c.comments_date.posted_date
end
--
You received this message because
Check out the guide on pre-compiling:
http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets
The default matcher for compiling files includes application.js,
application.css and all files that do not end in js or css
If you have other manifests or individual stylesheets and
If you have config.assets.compile set to true (typical for development) the
stylesheet_link_tag will attempt to look in your app/assets directory and
compile the css file if necessary. But the stylesheet_link_tag doesn't look
outside public/assets in when config.assets.compile is set to false
replace_html is a Prototype helper and has been deprecated in Rails 3.1
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/TGE1y-zZsy0J.
To post to
First of all it looks like you have a syntax error in the JavaScript:
$.(#search_new)
should be
$(#search_new)
If that doesn't fix the issue, there still might be something else wrong.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To
Check out the guide for routing, especially the part on specifying a
controller to use under customizing restful resources
http://guides.rubyonrails.org/routing.html#customizing-resourceful-routes
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk
You can also use the Rails delegate feature. I know you said you didn't want
to create the the AuthInfo model but I'm not sure there's any harm to it?
class User
has_one :auth_info
delegate :username, :username=, :password, :password=, :to = :auth_info
end
class AuthInfo
belongs_to :user
Perhaps take a look at line 4.
You're referencing :params[:search] but params is not a symbol. I think
perhaps you meant params[:search
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
If you want to redirect to a specific user_profile, you probably want to use
the singular helper:
user_profile_path(4)
The singular path accepts 2 arguments: id and format
The plural helper (user_profiles_path) is for the index action and only
accepts 1 argument: format
Run rake:routes to
I'm not quite sure what you're getting at here.
If you have a model named Post, you could easily find the record with ID of
10 by doing the following:
Post.find(10)
But if you truly do have an array of post instances, you can find the one
with ID of 10 using Enumerable.find:
array_name.find
You basically need to preview an input type=file before it has been
submitted? This sounds more like a JavaScript question than a Rails
question.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To view this discussion on the web visit
1 - 100 of 300 matches
Mail list logo