Showing posts with label RubyOnRails. Show all posts
Showing posts with label RubyOnRails. Show all posts

Friday, September 12, 2014

Rails Routing

Understanding Rails routing. Notes taken from the source (http://guides.rubyonrails.org/routing.html)
 
resources :photos
Creates seven different routes in your application, all mapping to the Photos controller:

HTTP Verb Path Controller#Action Used for
GET /photos photos#index display a list of all photos
GET /photos/new photos#new return an HTML form for creating a new photo
POST /photos photos#create create a new photo
GET /photos/:id photos#show display a specific photo
GET /photos/:id/edit photos#edit return an HTML form for editing a photo
PATCH/PUT /photos/:id photos#update update a specific photo
DELETE /photos/:id photos#destroy delete a specific photo

Thursday, August 28, 2014

Panda::APIError: NotAuthorized: Account with access key does not exist

Do anyone frustrated because of the NotAuthorized issue?

1.9.2-p320 :001 > Panda::Profile.all

Panda::APIError: NotAuthorized: Account with access key <<key>> does not exist

If you are setting the PandaStream Add ons through heruku document (https://devcenter.heroku.com/articles/pandastream), Please make sure you create an account in http://www.pandastream.com/ to get you access key and secret key. 

NOTE : PandaStream access key and secret key are different from Amazon S3 access key and secret key.


Notes from https://www.pandastream.com/docs/integrate_with_rails

Configuration

First you must log in to your account where you can find your credentials as follows:
  • Under Api Access: Access key, Secret key, API URL
  • After selecting your Cloud: Cloud ID

Notes from https://www.pandastream.com/docs/api#api_authentication

The Panda API requires all requests must also be signed to ensure they are valid and authenticated. For GET and DELETE requests the additional parameters must be url encoded and added to the parameters in the url. When making a POST or PUT request they should be included in the usual parameters payload submitted.
The access_key and secret_key used to authenticate the request are provided when you sign up for your Panda account. Your keys can always be found by logging in to your account by visiting pandastream.com


Thursday, October 10, 2013

Heroku: Permission denied (publickey). fatal: Could not read from remote repository.

You have make sure, you have added the heroku rsa public key to the server from your local machine

Check whether you have a file called "id_rsa.pub" in the .ssh folder. If not you have generate the key. 

Follow the steps:

1. To generate the key : $ ssh-keygen -t rsa
(You will get these prompts, press enter and continue
Enter file in which to save the key (/Users/TestUser/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: )

2.  Add the key to Heroku server : $ heroku keys:add ~/.ssh/id_rsa.pub

Reference : https://devcenter.heroku.com/articles/keys

Friday, September 13, 2013

Install PostgreSQL in Mac OX

You can install the PostgreSQL in MacOX in either way using Graphical Interface or through HomeBrew.

Click Here to choose the options : http://www.postgresql.org/download/macosx/

Here, I have used  Graphical installer

Before installing always make sure you are having the maximum shared memory. It is safe to begin the installation, it wont reserve any memory, so there in no harm...

To check the Shared memory : $ sysctl -a

kern.sysv.shmmax=1610612736
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
kern.maxproc=2048

If you don't have this config, please update your file $sudo vi /etc/sysctl.conf
[You can also get this info in Readme file.]

After editing, restart the machine, to install Postgres.

Double click the "postgresql-9.3.0-1-osx" and just follow the instruction.

To check whether Postgres is installed or not,

Run this cmd on the terminal :
psql -p 5432 -h localhost -U postgres --password

If it comes to the promt "postgres=#", then you are all set... Quit from the postgres console "\q"



Tuesday, September 10, 2013

Ruby Predefined Variables

This is a list of the frequently used predefined variables in ruby:

Exceptions
$! message of the last exception
$@ backtrace of the last exception

Regexp
$& the string that matched the last last regexp match
$` string preceding $&
$’ string following $&
$+ last parentheses match
$1, $2, $3… parentheses matches
$~ MatchData object containing information about the last match
$= case insensitive flag

Separators
$/ used by gets, readline etc. as a separator (defaults to “\n”)
$\ used by print, write etc. as a separator (defaults to nil)
$, used by Array#join
$; used by String#split

IO
$< program input
$> program output
$stdin standard input
$stdout standard output
$stderr standard error output
$. line number of the last read file
$_ last input line - used by gets, readline

Process
$0 program name
$* command line arguments
$$ PID of the program
$? exit status of the last process
$: $LOAD_PATH
$” all filenames required by the script
$SAFE security level 0-4, 0 having no restrictions and being the default
$DEBUG debugger enabled?

Friday, September 6, 2013

TryRuby

Learn ruby basic commands in 15 minutes using the link http://tryruby.org, Which has command line interpreter, and you can have short desc for each command. You can go back and forth to check.

Wednesday, August 28, 2013

ERROR: Error installing rails: activesupport requires Ruby version >= 1.9.3.

Check whether you are trying to install the correct version of Rails that are compatible with your Ruby Version.

You can check the ruby version by running the cmd "ruby -v"

Rails VersionPossible Ruby VersionsRecommended Ruby Version
1.0–2.11.8.61.8.6
2.21.8.6 or 1.8.71.8.7
2.31.8.6, 1.8.7, or 1.9.11.8.7
3.0–3.21.8.7, 1.9.2, or 1.9.31.9.3
4.0–…1.9.3, 2.0.x2.0.x

then try to install the rails

sudo gem install rails --version 3.2.12

Sunday, August 4, 2013

brew: command not found

If HomeBrew is not installed, Please follow the instruction mentioned here

1. Install XCode, check whether command line tools are installed or not.

2. $ gcc --version

3. It will display "i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."

4. Then you can execute the following command to install the home brew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

5. It will display "You should run `brew doctor' *before* you install anything." as last sentence after installing the home brew

6. Now type "$ brew doctor" .

7. Before implementing the recommendation, make sure whether it correct or not.

8. Finally, $brew update. That's it.

Reference : http://ricardianambivalence.com/2012/10/02/install-homebrew-on-your-mac-a-tutorial/

Install RVM Error

Can not find compiler and 'make' tool - make sure Xcode and/or Command Line Tools are installed.


1. Check whether you have install Xcode and its command line tools.

2. After installing the XCode, click on Xcode -> Preferences -> downloads

3. Check whether "Command Line Tools" got installed or not.