Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

ruby on rails - object.valid? returns false but object.errors.full_messages is empty -


i'm confuse objects can't save, simplified model

class subscription < activerecord::base     belongs_to :user, :class_name => "user", :foreign_key => "user_id" has_many :transactions, :class_name => "subscriptiontransaction"   validates_presence_of :first_name, :message => "ne peut être vide" validates_presence_of :last_name, :message => "ne peut être vide" validates_presence_of :card_number, :message => "ne peut être vide" validates_presence_of :card_verification, :message => "ne peut être vide" validates_presence_of :card_type, :message => "ne peut être vide" validates_presence_of :card_expires_on, :message => "ne peut être vide"  attr_accessor :card_number, :card_verification  validate_on_create :validate_card      def validate_card      unless credit_card.valid?         credit_card.errors.full_messages.each |message|             errors.add_to_base message         end     end end  def credit_card     @credit_card ||= activemerchant::billing::creditcard.new(         :type => card_type,         :number => card_number,         :verification_value => card_verification,         :month => card_expires_on.month,         :year => card_expires_on.year,         :first_name => first_name,         :last_name => last_name     ) end end  

and in subscription_controller

if subscription.save      # else      debugger # means breakpoint try subscription.errors.full_messages      # else end  

i tried use ruby-debug adding breakpoint tests

subscription.valid? #=> false  subscription.errors.full_messages #=> [] subscription.save! #=> activerecord::recordinvalid (validation failed:) 

which explains activerecord doesn't allow save method. unfortunately can't know why object invalid.

if have idea, thank you.

i had same problem. @ first had such code in model:

before_validation :set_some_param  def set_some_param    self.some_param = some_value end 

after changed to:

before_validation :set_some_param  def set_some_param    self.some_param = some_value    true end 

i see errors.

maybe have simular in code?


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -