2

I am new to Ruby on Rails and trying to achieve this:

I want to add a string column which is NOT NULL and holds the default value ''.

Here is my migration:

add_column :campaigns, :from_name, :string, limit: 100, :null => false, :defualt => ''

This migration works fine but when I see table in pgAdmin (PostgresQL) I see columns created but no default value:

from_name character varying(100) NOT NULL,

I tried same thing using pgAdmin and I could create

from_name character varying(100) NOT NULL DEFAULT ''::character varying,

What is wrong here??

7
  • 4
    You have a typo in your migration, ":defualt". So unless that's a copy error I suggest that's your problem. Commented Mar 5, 2013 at 10:42
  • Oh God! I feel very stupid having spent 2 hrs on this :( thanks a lot @MikeCampbell Commented Mar 5, 2013 at 10:49
  • 1
    @MikeCampbell just wonder why it didn't give any error/warning? Commented Mar 5, 2013 at 10:58
  • 1
    @Pramodtech Rails ignores arbitrary named parameters that are passed to migrations. Commented Mar 5, 2013 at 11:14
  • heh, no worries, we've all done it. and yep, @tamizhgeek is right. Commented Mar 5, 2013 at 11:48

1 Answer 1

7

It looks like you typed: defualt instead of default.

Try to fix that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.