Adding a devise user or admin in a Heroku app

To add a devise user on a Heroku site we combine two commands

Command 1: With devise a person can enter the following into their rails console to create a user: User.new(:email => "user@name.com", :password => 'password', :password_confirmation => 'password')

Command 2: To run commands in the Heroku terminal, simply go into local directory of the corresponding app and type heroku run [whatever you want to run]

So if we put those together we get the following, assuming that your user model is in fact called User:

    1. Change your directory to your app: cd ~/yourapp
    2. Enter into the rails console on Heroku with the following: heroku run rails c
    3. Run the create user code: U=User.new(:email => "user@name.com", :password => 'password', :password_confirmation => 'password')
    4. Then finally U.save

Finally, if you want to do this for a separate admin model, simply replace User in the instructions above with Admin (provided of course that’s what your separate admin model is called; if not adjust accordingly).

That’s it! You should be good to go!

Advertisements
Adding a devise user or admin in a Heroku app

Openmeetings use of country, state and country codes

I’ve been developing using openmeetings SOAP API for a little bit (on which I hope to post soon) and I spent a bit of time getting REALLY confused on where the user’s Country field comes from, what “states_id” is for the addNewUser service, what sort of input it expects, and where it’s stored.

Here it is:

States_id, from the SOAP API, defines the country and stores it in the table address.  (I suppose that makes sense.)  You can find it under the column state_id. This is how the user’s “Country” is defined in the user management gui (see below)om_country

But here’s where it gets weird.  You may have figured out that states_id expects a numerical input; however, this is NOT the standard E.164 three-digit country code that all of us can easily Google for.  Instead, the code is an index number corresponding to the country’s alphabetically organized row number in the Openmeetings table: state.  I think this is most likely a mistake, as the database contains all the Country Codes right there next to the id field, for seemingly, no reason at all.

So what to do?

For the time being, it’s pretty simple to get this working with this piece of information.  Simply enter the corresponding id number from the openmeetings table for states_id.  I’ve included the relevant columns below for reference:

mysql> select id, name from state;
+-----+------------------------------------------------------+
| id  | name                                                 |
+-----+------------------------------------------------------+
|   1 | Afghanistan                                          |
|   2 | Åland Islands                                        |
|   3 | Albania                                              |
|   4 | Algeria                                              |
|   5 | American Samoa                                       |
|   6 | Andorra                                              |
|   7 | Angola                                               |
|   8 | Anguilla                                             |
|   9 | Antigua and Barbuda                                  |
|  10 | Argentina                                            |
|  11 | Armenia                                              |
|  12 | Aruba                                                |
|  13 | Australia                                            |
|  14 | Austria                                              |
|  15 | Azerbaijan                                           |
|  16 | Bahamas                                              |
|  17 | Bahrain                                              |
|  18 | Bangladesh                                           |
|  19 | Barbados                                             |
|  20 | Belarus                                              |
|  21 | Belgium                                              |
|  22 | Belize                                               |
|  23 | Benin                                                |
|  24 | Bermuda                                              |
|  25 | Bhutan                                               |
|  26 | Bolivia                                              |
|  27 | Bosnia and Herzegovina                               |
|  28 | Botswana                                             |
|  29 | Brazil                                               |
|  30 | British Virgin Islands                               |
|  31 | Brunei Darussalam                                    |
|  32 | Bulgaria                                             |
|  33 | Burkina Faso                                         |
|  34 | Burundi                                              |
|  35 | Cambodia                                             |
|  36 | Cameroon                                             |
|  37 | Canada                                               |
|  38 | Cape Verde                                           |
|  39 | Cayman Islands                                       |
|  40 | Central African Republic                             |
|  41 | Chad                                                 |
|  42 | Channel Islands                                      |
|  43 | Chile                                                |
|  44 | China                                                |
|  45 | Hong Kong Special Administrative Region of China     |
|  46 | Macao Special Administrative Region of China         |
|  47 | Colombia                                             |
|  48 | Comoros                                              |
|  49 | Congo                                                |
|  50 | Cook Islands                                         |
|  51 | Costa Rica                                           |
|  52 | Côte d'Ivoire                                        |
|  53 | Croatia                                              |
|  54 | Cuba                                                 |
|  55 | Cyprus                                               |
|  56 | Czech Republic                                       |
|  57 | Democratic People's Republic of Korea                |
|  58 | Democratic Republic of the Congo                     |
|  59 | Denmark                                              |
|  60 | Djibouti                                             |
|  61 | Dominica                                             |
|  62 | Dominican Republic                                   |
|  63 | Ecuador                                              |
|  64 | Egypt                                                |
|  65 | El Salvador                                          |
|  66 | Equatorial Guinea                                    |
|  67 | Eritrea                                              |
|  68 | Estonia                                              |
|  69 | Ethiopia                                             |
|  70 | Faeroe Islands                                       |
|  71 | Falkland Islands (Malvinas)                          |
|  72 | Fiji                                                 |
|  73 | Finland                                              |
|  74 | France                                               |
|  75 | French Guiana                                        |
|  76 | French Polynesia                                     |
|  77 | Gabon                                                |
|  78 | Gambia                                               |
|  79 | Georgia                                              |
|  80 | Germany                                              |
|  81 | Ghana                                                |
|  82 | Gibraltar                                            |
|  83 | Greece                                               |
|  84 | Greenland                                            |
|  85 | Grenada                                              |
|  86 | Guadeloupe                                           |
|  87 | Guam                                                 |
|  88 | Guatemala                                            |
|  89 | Guernsey                                             |
|  90 | Guinea                                               |
|  91 | Guinea-Bissau                                        |
|  92 | Guyana                                               |
|  93 | Haiti                                                |
|  94 | Holy See                                             |
|  95 | Honduras                                             |
|  96 | Hungary                                              |
|  97 | Iceland                                              |
|  98 | India                                                |
|  99 | Indonesia                                            |
| 100 | Iran, Islamic Republic of                            |
| 101 | Iraq                                                 |
| 102 | Ireland                                              |
| 103 | Isle of Man                                          |
| 104 | Israel                                               |
| 105 | Italy                                                |
| 106 | Jamaica                                              |
| 107 | Japan                                                |
| 108 | Jersey                                               |
| 109 | Jordan                                               |
| 110 | Kazakhstan                                           |
| 111 | Kenya                                                |
| 112 | Kiribati                                             |
| 113 | Kuwait                                               |
| 114 | Kyrgyzstan                                           |
| 115 | Lao People's Democratic Republic                     |
| 116 | Latvia                                               |
| 117 | Lebanon                                              |
| 118 | Lesotho                                              |
| 119 | Liberia                                              |
| 120 | Libyan Arab Jamahiriya                               |
| 121 | Liechtenstein                                        |
| 122 | Lithuania                                            |
| 123 | Luxembourg                                           |
| 124 | Madagascar                                           |
| 125 | Malawi                                               |
| 126 | Malaysia                                             |
| 127 | Maldives                                             |
| 128 | Mali                                                 |
| 129 | Malta                                                |
| 130 | Marshall Islands                                     |
| 131 | Martinique                                           |
| 132 | Mauritania                                           |
| 133 | Mauritius                                            |
| 134 | Mayotte                                              |
| 135 | Mexico                                               |
| 136 | Micronesia, Federated States of                      |
| 137 | Monaco                                               |
| 138 | Mongolia                                             |
| 139 | Montenegro                                           |
| 140 | Montserrat                                           |
| 141 | Morocco                                              |
| 142 | Mozambique                                           |
| 143 | Myanmar                                              |
| 144 | Namibia                                              |
| 145 | Nauru                                                |
| 146 | Nepal                                                |
| 147 | Netherlands                                          |
| 148 | Netherlands Antilles                                 |
| 149 | New Caledonia                                        |
| 150 | New Zealand                                          |
| 151 | Nicaragua                                            |
| 152 | Niger                                                |
| 153 | Nigeria                                              |
| 154 | Niue                                                 |
| 155 | Norfolk Island                                       |
| 156 | Northern Mariana Islands                             |
| 157 | Norway                                               |
| 158 | Occupied Palestinian Territory                       |
| 159 | Oman                                                 |
| 160 | Pakistan                                             |
| 161 | Palau                                                |
| 162 | Panama                                               |
| 163 | Papua New Guinea                                     |
| 164 | Paraguay                                             |
| 165 | Peru                                                 |
| 166 | Philippines                                          |
| 167 | Pitcairn                                             |
| 168 | Poland                                               |
| 169 | Portugal                                             |
| 170 | Puerto Rico                                          |
| 171 | Qatar                                                |
| 172 | Republic of Korea                                    |
| 173 | Republic of Moldova                                  |
| 174 | Réunion                                              |
| 175 | Romania                                              |
| 176 | Russian Federation                                   |
| 177 | Rwanda                                               |
| 178 | Saint Helena                                         |
| 179 | Saint Kitts and Nevis                                |
| 180 | Saint Lucia                                          |
| 181 | Saint Pierre and Miquelon                            |
| 182 | Saint Vincent and the Grenadines                     |
| 183 | Samoa                                                |
| 184 | San Marino                                           |
| 185 | Sao Tome and Principe                                |
| 186 | Saudi Arabia                                         |
| 187 | Senegal                                              |
| 188 | Serbia                                               |
| 189 | Seychelles                                           |
| 190 | Sierra Leone                                         |
| 191 | Singapore                                            |
| 192 | Slovakia                                             |
| 193 | Slovenia                                             |
| 194 | Solomon Islands                                      |
| 195 | Somalia                                              |
| 196 | South Africa                                         |
| 197 | Spain                                                |
| 198 | Sri Lanka                                            |
| 199 | Sudan                                                |
| 200 | Suriname                                             |
| 201 | Svalbard and Jan Mayen Islands                       |
| 202 | Swaziland                                            |
| 203 | Sweden                                               |
| 204 | Switzerland                                          |
| 205 | Syrian Arab Republic                                 |
| 206 | Taiwan, Republic of China                            |
| 207 | Tajikistan                                           |
| 208 | Thailand                                             |
| 209 | The former Yugoslav Republic of Macedonia            |
| 210 | Timor-Leste                                          |
| 211 | Togo                                                 |
| 212 | Tokelau                                              |
| 213 | Tonga                                                |
| 214 | Trinidad and Tobago                                  |
| 215 | Tunisia                                              |
| 216 | Turkey                                               |
| 217 | Turkmenistan                                         |
| 218 | Turks and Caicos Islands                             |
| 219 | Tuvalu                                               |
| 220 | Uganda                                               |
| 221 | Ukraine                                              |
| 222 | United Arab Emirates                                 |
| 223 | United Kingdom of Great Britain and Northern Ireland |
| 224 | United Republic of Tanzania                          |
| 225 | United States of America                             |
| 226 | United States Virgin Islands                         |
| 227 | Uruguay                                              |
| 228 | Uzbekistan                                           |
| 229 | Vanuatu                                              |
| 230 | Venezuela (Bolivarian Republic of)                   |
| 231 | Viet Nam                                             |
| 232 | Wallis and Futuna Islands                            |
| 233 | Western Sahara                                       |
| 234 | Yemen                                                |
| 235 | Zambia                                               |
| 236 | Zimbabwe                                             |
+-----+------------------------------------------------------+

Anyway, hope that helps someone.

Oh one last interesting fact!

If you’re searching/grepping through the code, for the key word “address,” they spell it “adress”.  HOWEVER it is spelled “address” in the database in all instances I’ve seen so far.

Openmeetings use of country, state and country codes