Displaying 20 results from an estimated 300 matches similar to: "rescue ActiveRecord::RecordInvalid"
2009 Jun 05
6
rails 2.3.2
Hi all,
I am using rails v.2.3.2 and if I put following line to my
ApplicationController:
include LoginSystem
and I moved my login_system.rb to lib folder:
module LoginSystem
protected
def is_logged_in?
@logged_in_user = User.find(session[:user]) if session[:user]
end
def logged_in_user
return @logged_in_user if is_logged_in?
end
def logged_in_user=(user)
if
2012 May 15
1
How to handle ActiveRecord::RecordInvalid
I''m new to Rails. I''m using Service layer to keep my controllers thin. All
my service layer files are located in app/services/domain,
app/services/application and app/services/infrastructure. I''m using
services in active admin controller section. When validation fail it can''t
redirect correctly, it keeps throwing me ActiveRecord::RecordInvalid. Here
is the
2013 Aug 22
1
How do I deal with ActiveRecord::RecordInvalid: Validation failed:
Hello all,
I am currently writing model tests in rails 4. I am attempting to add an
error to a reservation object if the total number of reservations for a
given date and time has reached a pre-determined limit.
When my test runs, it is hitting the appropriate code but it is raising the
following error as opposed to just giving me an error in the object that I
can use.
2009 Mar 02
5
new project at the same domain
Hi,
just a quick question, is there a way how to run two apps on the same
domain?
Both for testing purposes. Thank you.
P.
--
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
2007 Aug 08
5
Can''t seem to spec a ActiveRecord::RecordInvalid exception properly...
1 def create
2 @user = User.new(params[:user])
3 @user.save!
4 self.current_user = @user
5 redirect_to user_path(@user)
6 flash[:notice] = "Thanks for signing up!"
7 rescue ActiveRecord::RecordInvalid
8 render :action => ''new''
9 end
I can''t seem to properly spec this out. I am trying numerous things, the
latest one is
2009 May 20
3
ffmpeg + mp3 convert
Hi all,
I am using paperclip plugin to upload mp3''s. Before I save the mp3 I
would like to convert it to a smaller size.
I am using ffmpeg library and in my Track model I am calling:
before_save :convert_mp3
def convert_mp3
system("ffmpeg -i #{mp3.to_file.path} -vn -ar 44100 -ac 2 -ab 64 -f
mp3 #{mp3.to_file.path}")
end
But this fails. Am I missing something?
2008 Nov 27
7
will_paginate issue
Hi,
I am trying paginate (will_paginate) users posts. It is counting and
showing the page links correctly, but still showing all the posts on one
page.
@entries = @user.entries.paginate :per_page => 5, :page =>
params[:page], :order => ''created_at DESC''
If I change it to @entries = Entry.paginate :per_page => 5 ........
It is fine, but I would like to show only
2015 Aug 12
2
Re: [PATCH 1/2] builder: add non-int revisions
On Wed, Aug 12, 2015 at 03:12:21PM +0200, Pino Toscano wrote:
> Add support for non-integer revisions of entries, comparing them as
> integer when possible.
Have you got an example of revisions? It may be possible to use
Common_utils.compare_version which does RPM revision-style comparison.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my
2015 Aug 12
0
Re: [PATCH 1/2] builder: add non-int revisions
On Wednesday 12 August 2015 17:08:42 Richard W.M. Jones wrote:
> On Wed, Aug 12, 2015 at 03:12:21PM +0200, Pino Toscano wrote:
> > Add support for non-integer revisions of entries, comparing them as
> > integer when possible.
>
> Have you got an example of revisions?
The Simple Streams README says about that:
* version_name:
A 'version' of a product represents
2007 Oct 26
5
specing rescue, ensure and else blocks of an Exception
Greetings,
I''m using rspec with rcov for my applications and there is one issue
which I cannot solve nor can find any proper information regarding
it: specing what is in a rescue block in case of an exception.
I''m using Ruby on Rails and I usually make use of exceptions in my
controllers, like the following example:
def action
@foo = Foo.find(1)
2008 Nov 30
2
How can I set default value for text_field?
Please this code:
<p>
<%= f.label :"Host Name" %><br />
<%= f.text_field :HostName %>
</p>
I want to set a default to this text field, how can I do this?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2008 Dec 05
1
page views counter
Hi all,
I''ve made a really simple page views counter.
def show
@post = Post.find......
addcount = @post.views += 1
@post.update_attribute "views", addcount
end
Its working fine, but if someone hold the F5 key, it keeps counting and
counting. Which is not a really good. Is there a way how to force the
counter to not keep counting while someone is holding the F5 key?
THX
2007 Jan 09
12
Asterisk build for Suse 10.1
Has anyone heard of a build or instructions for installing Asterisk on a
Suse 10.1 system?
Bob Rawlinson
2007 May 20
9
How to test for exceptions
Hi folks,
I''m in the process of converting a Test::Unit functional test to RSpec, but I''ve run into a slight problem. I tried looking through the documentation but I still don''t know what I missed.
Thanks in advance,
Blake
describe VenuesController, "on update" do
before(:each) do
@venue = mock("venue")
2006 Nov 22
3
Controller Isolation
Hi,
I have a project that I had running under rspec 0.6.x and recently upgraded
to 0.7.2.
I am trying to isolate my controllers from the database as I go through and
change all the specs to run under 0.7.2.
I am having a problem where I need to make the create! method return the
mocked object as well as raise RecordInvalid exception. Is this at all
possible?
I use the rescue statement in my
2009 Jul 04
12
save! not allowed after validates_uniqueness
I have this in a model
validates_uniqueness_of :aspect, :scope => :user_id
In an instance method of the same model I have "save!" but I don''t touch
the :aspect attribute in that instance method at all.
Whenever that save! command is run however I get this error:
ActiveRecord::RecordInvalid: Validation failed: Aspect has
already been taken
I don''t
2011 Sep 01
2
Custom ActiveRecord Error Message
I''m generating 3 models on 1 controller and i''m rescuing
ActiveRecord::RecordInvalid for validation errors, however 2 of the
models have the same attribute called "name", and if there''s an error on
that field, I wouldn''t know whether that belongs to model A or model B.
What then is the best way of modifying the error message of a validation
error
2007 Sep 13
2
Failing to raise an exception in a stub
I''ve come across rather strange behaviour when trying to raise an
exception in a stubbed method.
I''m speccing the behaviour of a Rails create action, where I''m using
save! to catch failed saves. In the case of working save, I''m using
the following stub:
@client.stub!(:save!).and_return(true)
which works fine.
However, in the negative case,
2007 Nov 17
7
Down with Lambda!!
Rspec is all about using natural language to define behavior. In this
context, I feel that lambda is sorely out of place. I was chatting on
#irc and a pal of mine (wycats) proposed an interesting alternative:
alias_method :doing, :lambda
so instead of something like
lambda {post :create, {:title => nil}}.should
raise_error(ActiveRecord::RecordInvalid)
we get
doing {post :create, {:title
2006 Mar 19
2
Functional Testing
Hey all,
I have a many-to-many relationship (Questions
has_and_belongs_to_many Answers), and when I destroy
the Question (the one) I also destroy all the Answers
(the many).
Since the following doesn''t seem to work for
has_and_belongs_to_many:
class Question < AR::Base...
has_and_belongs_to_many :answers, :dependent =>
:destroy
end
I have this embedded in a transaction block