Daily Archives

Articles indexed Monday January 3 2011

Page 6/33 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Decimal point removed from decimals in a Serialized XML

    - by MiguelM
    I'm using XmlSerializer with classes created from a xsd using xsd.exe. It has worked fine for months. Now I'm receiving reports that in some cases the created xml file has all decimals serialized without a decimal point, e.g. 123.45 is serialized as 12345. I haven't been able to reproduce the problem, but I'm suspecting it may be related to localization. This is my first C# project, so I may be overlooking something basic. Could localization cause this problem? How can I make the serialization process locale independent? Any idea of something else that could cause this problem?

    Read the article

  • BigInteger.pow(BigInteger) ?

    - by PeterW
    I'm playing with numbers in Java, and want to see how big a number I can make. It is my understanding that BigInteger can hold a number of infinite size, so long as my computer has enough Memory to hold such a number, correct? My problem is that BigInteger.pow accepts only an int, not another BigInteger, which means I can only use a number up to 2,147,483,647 as the exponent. Is it possible to use the BigInteger class as such? BigInteger.pow(BigInteger) Thanks.

    Read the article

  • pySerial writes to Arduino Uno get buffered

    - by Bhaktavatsalam Nallanthighal
    I have a Python script that writes short messages to the serial port on my Arduino Uno board using pySerial. There is a loop and depending on some conditions, multiple writes can happen within a loop, something like this: while True: #Conditions block 1 if <CONDITION1>: serial.writelines("INIT") elif <CONDITION2>: serial.writelines("NEW") ... #Conditions block 2 if <CONDITION1>: # Fetch something from the Internet serial.writelines("CHECK") elif <CONDITION2>: # Fetch something from the Internet serial.writelines("STOP") ... But, when my Arduino board receives this it receives the first message as INIT, but the second one is being read as INITSTOP or INITCHECK and third one gets concatenated to the previous messages. My arduino program checks for specific message in this way: if(msg.equals("CHECK")) { // Do something } else if(msg.equals("INIT")) { // Do Something else } Can anyone guide me on this? BTW, I don't think the problem is with the Arduino as it works perfectly when I test it with the Serial Monitor available with the IDE. I've tried adding sleeps of upto 10 seconds before every write, but that did not work out.

    Read the article

  • Getting the class of an n dimensional array of an runtime supplied class name

    - by MeBigFatGuy
    Given a fully qualified class name, and a number of dimensions, i would like to get the Class name for this class. I believe i can do this like such public Class<?> getArrayClass(String className, int dimensions) throws ClassNotFoundException { Class<?> elementType = Class.forName(className); return Array.newInstance(elementType, new int[dimensions]).getClass(); } However this requires me to create an unneeded instance of the class. Is there a way to do this without creating the instance? It does not appear that Class.forName("[[[[Ljava/lang/String;") (or a algorithmically generated version) works correctly in all instances from various blog posts i've seen.

    Read the article

  • What is the difference between binding data in data grid view methods ??

    - by Ashish
    What is the difference between binding data in data grid view methods ?? <ItemTemplate> <asp:LinkButton ID="lnkBtnUserName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"UserFirstName")%>' CommandArgument='<%# Eval("UserID") %>' OnClick="lnkBtnUserName_Click" /> </ItemTemplate> and this second one <asp:TemplateField HeaderText="Employee ID"> <ItemTemplate> <asp:Label ID="lblempid" runat="server" Text='<%# Bind("EmpId.EmpId") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> means in method 1 Text='<%# DataBinder.Eval(Container.DataItem,"UserFirstName")%>' CommandArgument='<%# Eval("UserID") %>' method 2 Text='<%# Bind("EmpId.EmpId") also explain use one this CommandArgument='<%# Eval("UserID") in 1st one ????

    Read the article

  • Spring-Security http-basic auth in addition to other authentication types

    - by Keith
    I have a pretty standard existing webapp using spring security that requires a database-backed form login for user-specific paths (such as /user/**), and some completely open and public paths (such as /index.html). However, as this webapp is still under development, I'd like to add a http-basic popup across all paths (/**) to add some privacy. Therefore, I'm trying to add a http-basic popup that asks for a universal user/pass combo (ex admin/foo) that would be required to view any path, but then still keep intact all of the other underlying authentication mechanisms. I can't really do anything with the <http> tag, since that will confuse the "keep out the nosy crawlers" authentication with the "user login" authentication, and I'm not seeing any way to associate different paths with different authentication mechanisms. Is there some way to do this with spring security? Alternatively, is there some kind of a dead simple filter that I can apply independently of spring-security's authentication mechanisms?

    Read the article

  • Lookups in Multi-Tenant Database

    - by Huthaifa Afanah
    I am developing a SaaS application and I am looking for the best way to design lookup tables, taking in consideration: The look-up tables will have predefined data shared among all the tenants Each tenant must have the ability to extend the look-up table with his own data e.g adding a car class not defined I am thinking about adding TenantID column to each lookup and add the predefined data with setting that column to some value which represents the "Super Tenant" that belongs to the system itself

    Read the article

  • problem with .htaccess and mod_rewrite

    - by ian
    My below .htaccess file should send everything to my index.php page where my framework [Fat Free Frameowkr] handles it. However if I go to http://www.site.com/ it works. If I go to http://www.site.com/about I get a 404 error. Any ideas? # Enable rewrite engine and route requests to framework RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L,QSA] # Disable ETags Header Unset ETag FileETag none # Default expires header if none specified (stay in browser cache for 7 days) <IfModule mod_expires.c> ExpiresActive On ExpiresDefault A604800 </IfModule>

    Read the article

  • How to extract the data from data.store to an array?

    - by Prateek Raj
    Hi everyone, i have the class var prstore = new Ext.data.Store({ url: 'xmlformat.xml', autoLoad: true, reader: new Ext.data.XmlReader({ record: 'price' }, [{name: 'Pri', mapping: '@rate'}]) }); the data which is stored in the "prstore",i want it to copy it into an array. something like var hello = []; hello = prstore.getrange(); but it's not working for me please help thank you

    Read the article

  • How to configure a specific service operation to be accessible through a different End Point

    - by pradeeptp
    I have single service contract that has 2 service operations. Let me call these operations as X1 and X2. How do I configure X1 to be accessible through HTTP and X2 to be accessible through TCP/IP. If I configure the service contract to be accessibel to TCP/IP end point then both X1 and X2 will be accessible through TCP/IP. Same is the case if I configure the same service contract with HTTP protocol. I could have two different service contracts for achieving what I want, but I want to know if I could achieve the same through a single service contract.

    Read the article

  • adding hobby to a user

    - by rookieRailer
    I'm trying to write a rails application. I'm a ruby-on-rails newbie. I have a User model and a Hobby model. class User < ActiveRecord::Base has_many :hobbies end class Hobby < ActiveRecord::Base belongs_to :user end During the new user registration, I have used a text box where I enter a value for hobby. Then, when I press a button 'Add hobby', a method in UsersController add_hobby is to be called where I intend to append the value entered for hobby by user to the user i.e @user.hobbies << hobby However, my problem is that the user object has not been saved yet, so there is no way to access a particular user object. How do I get around this problem ?

    Read the article

  • How to check if a string has earlier been set using iabbr (full match)

    - by Sumit
    I am trying to check if a lhs is already abbreviated in vim. mapcheck, however, seems to have a problem. For example, iabbr swt switch echo mapcheck('sw','i',1) returns "switch" even when "switch" defined for "swt". mapargs seem to return a string even if there is a partial match with the lhs. Is there a way to find if an abbreviation has been defined for the "exact" match, i.e., the above mapcheck returning a "" instead.

    Read the article

  • Integration of SharePoint 2010 with TFS2010

    - by Kabir Rao
    We have performed following steps as of now- Install TFS2010 10.0.30319.1 (RTM) on Windows Server 2008 R2 Enterprise(app tier) SQL 2008 SP1 with Cumulative update 2 on Windows Server 2008 R2 Enterprise(data tier) Reporting Service is installed on app tier. After this installation worked fine we installed SharePoint 2010 on app tier. After installation we followed http://blogs.msdn.com/b/team_foundation/archive/2010/03/06/configuring-sharepoint-server-2010-beta-for-dashboard-compatibility-with-tfs-2010-beta2-rc.aspx for configuration. We are not able to perform the last step described in the link as following error occured- TF249063: The following Web service is not available: http://apptier:31254/_vti_bin/TeamFoundationIntegrationService.asmx. This Web service is used for the Team Foundation Server Extensions for SharePoint Products. The underlying error is: The remote server returned an error: (404) Not Found.. Verify that the following URL points to a valid SharePoint Web application and that the application is available: http://apptier:31254. If the URL is correct and the Web application is operating normally, verify that a firewall is not blocking access to the Web application. We have also noticed that Document Folder in Team project also have red x. Please help. Thanks upfront.

    Read the article

  • Window 2003 is PHP Limiting my Download Speed?

    - by JohnScout
    Hello, I have window 2003 100mbps server, i have tried using php script such as php indexer, zina pancake.org and others. The php script use to serve download such as images and music songs. I personally have 20mbps internet speed. When i use the php script (download pass thru PHP headers) , it will download at constant speed of 30-40KBps. I have tried different webserver such as apache 1.3, apache 2.2, abyss webserver & lighttpd for windows. The speed while relying on php is same constant 30-40KBps however when i tried direct link/straight from apache, the speed is 1MB/s. Is there any settings in Window 2003 Registry or PHP should i change to make the download speed is more faster when going thru PHP?

    Read the article

  • vsftpd chroot_local_user does nothing

    - by Reinderien
    Hello all. I'm setting up a vsftpd server on: Linux 2.6.32-26-server #48-Ubuntu SMP Wed Nov 24 10:28:32 UTC 2010 x86_64 GNU/Linux When I set chroot_local_user=YES, there is no effect (I can still see / when I log in). There is nothing in syslog or /var/log/vsftpd.log to indicate what's wrong. I know that I'm editing the right conf file and that other settings do come into effect when I restart the daemon, because these work: ssl_enable=YES force_local_data_ssl=YES force_local_logins_ssl=YES Any idea what's wrong? Thanks.

    Read the article

  • what determines the bios you can use

    - by andy
    I have a Compaq sr5710f with a MCP61PM-HM (Iris8) motherboard and loaded a Geforce6100sm-m bios on to it. It works fine and opened up some options, but I want to give my comp am3 socket support. So my question is if I go looking for a bios that will do that for me what do I need to pay attention to. Is it only the chip set which is geforce 6150se nforce 405 or are there more things I should be looking at. If anyone thinks they might know a bios that will help me out that would be good to. I am looking for a retail bios though. I do not want to load any of the experimental ones you can find on the net. Also I would need it to support ddr2 800 ram, and would like to keep am2 support to. I know my bios is data that is downloaded onto my motherboard, or for lack of a better word a program. I am currently running a bios that is not for my motherboard, so I know it can be done. What I need is what do I need to pay attention to when looking for compatible bios programs, that is not for my motherboard.

    Read the article

  • Problems with chip fan and CPU fan

    - by JS Bangs
    I have a five-year-old ASUS motherboard that has been working fine for me for years, until I attempted to power it on yesterday and got a CPU fan speed and chip fan speed warning. Cracking open the case and powering the computer on, I can see the chip fan working, but it appears to be hitting something as it makes a very loud buzzing noise. The CPU fan, meanwhile, starts up when I power on, but slows down and stops after a few seconds! How can I address these problems? Is there any way to fix these sort of fan speed issues without just replacing the fan (which in the case of the chip fan, probably means replacing the whole motherboard)?

    Read the article

  • SSH error 114 when connect with FinalBuilder 7

    - by mamcx
    I'm testing FB 7 and try to connect to my Mac OS X Snow Leopard machine. I can connect with paramiko (python SSH library) but not FB7. The only thing I get is: SSH error encoutered: 114 I try stopping & restarting the share session on Mac OS X. update: I enable server debug and get this log: debug1: sshd version OpenSSH_5.2p1 debug1: read PEM private key done: type RSA debug1: private host key: #0 type 1 RSA debug1: read PEM private key done: type DSA debug1: private host key: #1 type 2 DSA debug1: rexec_argv[0]='/usr/sbin/sshd' debug1: rexec_argv[1]='-Dd' debug1: Bind to port 22 on ::. Server listening on :: port 22. debug1: Bind to port 22 on 0.0.0.0. Server listening on 0.0.0.0 port 22. debug1: fd 5 clearing O_NONBLOCK debug1: Server will not fork when running in debugging mode. debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8 debug1: inetd sockets after dupping: 3, 3 Connection from 10.3.7.135 port 49457 debug1: Client protocol version 2.0; client software version SecureBlackbox.8 debug1: no match: SecureBlackbox.8 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.2 debug1: privsep_preauth: successfully loaded Seatbelt profile for unprivileged child debug1: permanently_set_uid: 75/75 debug1: list_hostkey_types: ssh-rsa,ssh-dss debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: client->server aes128-ctr [email protected] none debug1: kex: server->client aes128-ctr [email protected] none debug1: expecting SSH2_MSG_KEXDH_INIT debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: KEX done debug1: userauth-request for user mamcx service ssh-connection method none debug1: attempt 0 failures 0 debug1: PAM: initializing for "mamcx" Connection closed by 10.3.7.135 debug1: do_cleanup debug1: PAM: setting PAM_RHOST to "10.3.7.135" debug1: do_cleanup debug1: PAM: cleanup debug1: audit_event: unhandled event 12

    Read the article

  • What type of wireless adapter for Verizon Fios?

    - by ShoeLace1291
    I have verizon fios internet service. I believe they use a Wireless G router, but I just have one question. I currently am using a 54mbps wireless pci adapter in my Windows 7 custom build. It drops the internet connection all the time and is starting to get very irritating. I'm thinking about buying a new one, but all the 300mbps cards on newegg are wireless n. So my question is, will a wireless n network adapter make a difference with a wireless g router?

    Read the article

  • apt-get update stuck on "Waiting for Headers"

    - by crasic
    I'm setting up a Maverick server on a spare PC. The install completes fine and the system boots up into the shell. However, when I try to do a apt-get update , apt hangs on almost every entry with the message 99% [Waiting for headers] sometimes a message of 96 b/s appears on the far right. The actual percent that it claims also varies. Searching around online gave a potential solution by using the option Acquire::http::Pipeline-Depth="0" this somewhat alleviates the problem, i.e. it stalls on every other entry with the same message as above. If you wait it out (the whole update took about 4 hours), the update still fails as a good portion of the hits show a "unable to connect" or similar message, despite the fact that I can ping the server from the pc just fine. The problem is also unrelated to the mirror used since I've tried about a dozen mirrors with no success, I've even tried commenting out everything but the main entry in sources.list and it still refuses to update. The network connection is fine since I can ping and wget (apt won't let me install lynx until I run a successful update) just fine. I've also reinstalled the distro with no luck. The only thing weird about the setup is that the PC is connecting to the internet through my windows laptop with ICS configured properly, but as I've said before, the network connection is fine.

    Read the article

  • filesystem types for partitions

    - by Tim
    I am going to dual-boot install Ubuntu1 10.04 on my laptop with Windows 7. I was wondering what filesystem types (such as ext2, ext3, ext4, ReiserFS and whatever might come into mind) are recommended for various possible partitions (such as /, home, /boot, swap, and others that might come into mind)and why? if ext4 is now stable enough for use for partitions in Ubuntu and Shared partition between Windows and Ubuntu? what journaling Options (writeback, ordered and journal) are recommended for each partition's filesystem? Thanks and regards!

    Read the article

  • converting date data type into varchar

    - by Sheetal Inani
    I have some dates fields in table. These columns contain dates in the following format: mmddyy For example: 31/12/2010 00:00:00:0000 I need to import these values into a table which is set to varchar and numeric and formats dates like this: monthName varchar Year numeric(4,0) currently I'm using INSERT INTO [School].[dbo].[TeacherAttendenceDet] ([TeacherCode], [MonthName], [Year]) (SELECT MAX(employeecode), Datename(MONTH, dateofjoining) AS MONTH, Datepart(YEAR, dateofjoining) AS DATE FROM employeedet GROUP BY dateofjoining) but datename() gives result in date format.. I have to save it in varchar format How can I do this? this is employeemast table: EmployeeCode numeric(5, 0) PayScaleCode numeric(7, 0) DesignationCode varchar(50) CityCode numeric(5, 0) EmployeeName varchar(50) FatherName varchar(50) BirthDate varchar(50) DateOfJoining varchar(50) Address varchar(150) this is TeacherAttendenceDet table TeacherCode numeric(5, 0) Unchecked Year numeric(4, 0) Unchecked MonthName varchar(12) Unchecked i have to insert in teacherattendencedet table the monthname and year from employeemast

    Read the article

  • SQL Select Upcoming Birthdays

    - by Crob
    I'm trying to write a stored procedure to select employees who have birthdays that are upcoming. SELECT * FROM Employees WHERE Birthday > @Today AND Birthday < @Today + @NumDays This will not work because the birth year is part of Birthday, so if my birthday was '09-18-1983' that will not fall between '09-18-2008' and '09-25-2008'. Is there a way to ignore the year portion of date fields and just compare month/days? This will be run every monday morning to alert managers of birthdays upcoming, so it possibly will span new years. Here is the working solution that I ended up creating, thanks Kogus. SELECT * FROM Employees WHERE Cast(DATEDIFF(dd, birthdt, getDate()) / 365.25 as int) - Cast(DATEDIFF(dd, birthdt, futureDate) / 365.25 as int) <> 0

    Read the article

  • Sqlite3 : "Database is locked" error

    - by Miraaj
    Hi all, In my cocoa application I am maintaining a SQLite db within resources folder and trying to do some select, delete operations in it but after some time it starts giving me 'Database is locked' error. The methods which I am using for select delete operations are as follows: // method to retrieve data if (sqlite3_open([databasePath UTF8String], &database) != SQLITE_OK) { sqlite3_close(database); NSAssert(0, @"Failed to open database"); } NSLog(@"mailBodyFor:%d andFlag:%d andFlag:%@",UId,x,Ffolder); NSMutableArray *recordsToReturn = [[NSMutableArray alloc] initWithCapacity:2]; NSString *tempMsg; const char *sqlStatementNew; NSLog(@"before switch"); switch (x) { case 9: // tempMsg=[NSString stringWithFormat:@"SELECT * FROM users_messages"]; tempMsg=[NSString stringWithFormat:@"SELECT message,AttachFileOriName as oriFileName,AttachmentFileName as fileName FROM users_messages WHERE id = (select message_id from users_messages_status where id= '%d')",UId]; NSLog(@"mail body query - %@",tempMsg); break; default: break; } sqlStatementNew = [tempMsg cStringUsingEncoding:NSUTF8StringEncoding]; sqlite3_stmt *compiledStatementNew; NSLog(@"before if statement"); if(sqlite3_prepare_v2(database, sqlStatementNew, -1, &compiledStatementNew, NULL) == SQLITE_OK) { NSLog(@"the sql is finalized"); while(sqlite3_step(compiledStatementNew) == SQLITE_ROW) { NSMutableDictionary *recordDict = [[NSMutableDictionary alloc] initWithCapacity:3]; NSString *message; if((char *)sqlite3_column_text(compiledStatementNew, 0)){ message = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatementNew, 0)]; } else{ message = @""; } NSLog(@"message - %@",message); NSString *oriFileName; if((char *)sqlite3_column_text(compiledStatementNew, 1)){ oriFileName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatementNew, 1)]; } else{ oriFileName = @""; } NSLog(@"oriFileName - %@",oriFileName); NSString *fileName; if((char *)sqlite3_column_text(compiledStatementNew, 2)){ fileName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatementNew, 2)]; } else{ fileName = @""; } NSLog(@"fileName - %@",fileName); [recordDict setObject:message forKey:@"message"]; [recordDict setObject:oriFileName forKey:@"oriFileName"]; [recordDict setObject:fileName forKey:@"fileName"]; [recordsToReturn addObject:recordDict]; [recordDict release]; } sqlite3_finalize(compiledStatementNew); sqlite3_close(database); NSLog(@"user messages return -%@",recordsToReturn); return recordsToReturn; } else{ NSLog(@"Error while creating retrieving mailBodyFor in messaging '%s'", sqlite3_errmsg(database)); sqlite3_close(database); } // method to delete data if (sqlite3_open([databasePath UTF8String], &database) != SQLITE_OK) { sqlite3_close(database); NSAssert(0, @"Failed to open database"); } NSString *deleteQuery = [[NSString alloc] initWithFormat:@"delete from users_messages_status where id IN(%@)",ids]; NSLog(@"users_messages_status msg deleteQuery - %@",deleteQuery); sqlite3_stmt *deleteStmnt; const char *sql = [deleteQuery cStringUsingEncoding:NSUTF8StringEncoding]; if(sqlite3_prepare_v2(database, sql, -1, &deleteStmnt, NULL) != SQLITE_OK){ NSLog(@"Error while creating delete statement. '%s'", sqlite3_errmsg(database)); } else{ NSLog(@"successful deletion from users_messages"); } if(SQLITE_DONE != sqlite3_step(deleteStmnt)){ NSLog(@"Error while deleting. '%s'", sqlite3_errmsg(database)); } sqlite3_close(database); Things are going wrong in this sequence Data is retrieved 'Database is locked' error arises on performing delete operation. When I retry to perform 1st step.. it now gives same error. Can anyone suggest me: If I am doing anything wrong or missing some check? Is there any way to unlock it when it gives locked error? Thanks, Miraaj

    Read the article

  • Login or Register (Ruby on rails)

    - by DanielZ
    Hello stackoverflow, I'm working on an Ruby on Rails application (2.3.x) and i want to make a form that lets the user login or register. I want to do this in the same form. I have a JS function that replaces the form elements like this: Login form: <% form_for @user do |f| %> <div id="form"> <%= f.label :email, "E-mail" %> <%= f.text_field :email %> <%= f.label :password, "Password" %> <%= f.password_field :password %> <%= link_to "I don't have an account, "#", :id => "changeForm"%> <%= f.submit "Login" %> </div> <% end %> The id "changeForm" triggers a JS function that changes the form elements. So if you press the url the html looks like this: <% form_for @user do |f| %> <div id="form"> <%= f.label :name, "Name" %> <%= f.text_field :name %> <%= f.label :email, "E-mail" %> <%= f.text_field :email %> <%= f.label :password, "Password" %> <%= f.password_field :password %> <%= f.label :password_confirmation, "Password confirmation" %> <%= f.password_field :password_confirmation %> <%= link_to "I do have an account, "#", :id => "changeForm"%> <%= f.submit "Register" %> </div> <% end %> I added the neccesary validations to my user model: class User < ActiveRecord::Base attr_reader :password validates_presence_of :name, :email, :password validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates_confirmation_of :password But what happens when you fill in the email / password you get the errors that the name is missing and that the password fields aren't confirmed. So i could do some nasty programming in my user model like this: #if password_conf or the name are present the user has tried to register... if params[:user][:password_confirmation].present? || params[:user][:name].present? #so we'll try to save the user if @user.save #if the user is saved authenticate the user current_session.user = User.authenticate(params[:user]) #if the user is logged in? if current_session.user.present? flash[:notice] = "succesvully logged redirect_to some_routes_path else #not logged in... flash[:notice] = "Not logged in" render :action => "new" end else #user not saved render :action => "new" end else #So if the params[:user][:password_confirmation] or [:user][:name] weren't present we geuss the user wants to login... current_session.user = User.authenticate(params[:user]) #are we logged_in? if current_session.user.present? flash[:notice] = "Succesvully logged in" redirect_to some_routes_path else #errors toevoegen @user.errors.add(:email, "The combination of email/password isn't valid") @user.errors.add(:password," ") render :action => "new" end end end Without validations this (imho dirty code and should not be in the controller) works. But i want to use the validates_presence_of methods and i don't want to slap the "conventions over configurations" in the face. So another thing i have tried is adding a hidden field to the form: #login form <%= f.hidden_field :login, :value => true %> # and ofcourse set it to false if we want to register. And then i wanted to use the method: before_validation before_validation_on_create do |user| if params[:user].login == true #throws an error i know... validates_presence_of :email, :password validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i else validates_presence_of :name, :email, :password validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates_confirmation_of :password end end But this doesn't work because i can't access the params. And login isn't a attribute for the user object. But i thought that in this way i could validate the email and password params if the user wants to login. And all the other attrs if the user want to register. So all i could think of doesn't work how i want it to work. So my main goal is this: 1 form for login/register with the use of the validation methods in the user model. So if we want to login but don't fill in any information = give validation errors. And if the user wants to login but the email/password combination doens't match give the "@user.errors.add(:email, "the combination wasn't found in the db...")". And the same goes for user register... Thanks in advance!

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >