Don't wanna be here? Send us removal request.
Text
Page Extractor Testing
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam enim justo, egestas vel turpis in, aliquam aliquet ante. Suspendisse vitae erat eget dolor varius ultricies. Fusce rhoncus nisi non elementum aliquet. Sed auctor ex sed massa maximus viverra. Vivamus dictum quam accumsan, molestie enim in, cursus lectus. Fusce interdum suscipit nunc et pharetra. Sed auctor quam vitae dapibus facilisis. Nullam eget sapien et dolor feugiat sagittis. Morbi viverra sapien eu libero laoreet tincidunt. Vestibulum mattis nisl id augue interdum mattis. Proin at rutrum dolor. In euismod auctor nisi congue tempus. Nunc mollis tortor et pulvinar egestas. Morbi posuere vulputate maximus. Phasellus quis mollis tellus. Vivamus sed tortor in turpis faucibus feugiat.
In ac magna rhoncus, aliquet tellus sed, rutrum nisl. Aenean consectetur arcu mi, non suscipit odio gravida id. Suspendisse potenti. Ut eu ornare metus. Praesent sit amet dictum odio. Sed mattis ultrices elit, id congue tellus blandit quis. Donec congue ipsum et nisl fermentum, convallis rutrum nibh tempus. Nam eu leo lectus. Aenean ornare vel quam tincidunt blandit.
Nunc ac cursus nisl, eget molestie libero. Cras ornare blandit augue, sit amet sodales nisi tincidunt a. Nullam ac augue a nisi scelerisque bibendum. Fusce efficitur dictum ipsum nec eleifend. Sed maximus maximus efficitur. Curabitur aliquet lorem vel neque posuere, at convallis mi placerat. Integer convallis posuere dui a ultricies. Interdum et malesuada fames ac ante ipsum primis in faucibus. Maecenas lobortis et tellus vel rutrum. Phasellus vitae accumsan enim. Aenean porttitor luctus odio, sit amet gravida justo porttitor in. Suspendisse tempus ex ac libero tristique, eu ultricies arcu iaculis. Ut bibendum euismod lacus a vulputate. Nam ornare turpis in enim iaculis, id suscipit nisi pulvinar. Morbi eu scelerisque lacus. Cras eleifend nunc a mollis egestas.
0 notes
Text
Installing mysql2 in Windows 7
Download and Install mysql connector from mysql.com
copy libmysql.dll to ruby\bin
gem install mysql2 -- '--with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.5\include"
C:\Users\Senthil Kumar\Desktop>gem install mysql2 -- '--with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.5\include" Temporarily enhancing PATH to include DevKit... Building native extensions with: '--with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.5\lib" --w ith-mysql-include="C:\Program Files\MySQL\MySQL Server 5.5\include"' This could take a while... Successfully installed mysql2-0.3.13 Parsing documentation for mysql2-0.3.13 unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/mysql2/mysql2.so, skipping Installing ri documentation for mysql2-0.3.13 1 gem installed
0 notes
Text
Heroku on Rails
gem install heroku
heroku keys:add email: [email protected] password: *****
git clone [email protected]
git diff
git status
git add db/migrate
git commit -am "Fixes ...."
git push
heroku rake db:migrate
0 notes
Text
Difference between _url and _path in rails
_url
It specifies the full path of the browser path along with the host name.
example
users_url
http://localhost:3000/users
_path
It only specifies the protocol path alone.
example
users_path
/users
note:
if u want to change the host path, use :host =>""
users_url(:host => "http://localhost:3001")
0 notes
Text
Getting column name from the table in rails
>> User
=> User(id:integer, name:string, password:string)
To get the array of column names
>> User.column_names
=> ["id", "name", "password"]
To print the individual column names
>> User.column_names.each do |column|
>> puts column
>> end
=> id
=> name
=> password
=> nil
=> ["id", "name", "password"]
0 notes
Text
HAML in rails
HAML (HTML Abstraction Markup Language)
To run haml into rails follow the below steps
gem install haml
rails senthil -d mysql
cd senthil
ruby script/generate controller Hello index
rake db:create
Configuring the haml.
go to the \config\environment.rb and add the following line
config.gem "haml"
Rename index.html.erb to index.html.haml
Replace the coding with following code.
%h1 Hello#index %p HELLO EVERYONE
Now run the server.
ruby script/server
go to the browser and open up http://localhost:3000/home, u can see the encrypted haml coding there.
For Reference
Element tag (p, span, strong ... except div tag) use % before the element name.
For Class Element use . before the class element.
For ID Element use # before the id element.
No need to specify div tag, u can simply use class element or id element.
Multiple compination
%span {:class => "class_name", :id => "id_name"} Hello, Sagework!
%span.class_name#id_name Hello, Sagework!
Dynamic Tags
<%= %> use just = alone.
<% %> use just - alone.
0 notes
Text
Searching available gems locally and in remote
Local
gem list --local rails
(or)
gem list -l rails
Remote
gem list --remote rails
(or)
gem list -r rails
0 notes
Text
Running Test Case for particular files in Rails 3
>> rails sample -d mysql
>> cd sample
>> rails g scaffold User name:string email:string
>> rake db:create:all
>> rake db:migrate
To run the particular test case i.e. user_test.rb use the following steps.
>> ruby -Itest test\unit\user_test.rb
Loaded suite test/unit/user_test Started . Finished in 3.868800 seconds.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 57429
0 notes
Text
Alternate for assert_valid in Rails 3
Alternate for assert_valid in Rails 3
Rails 2.x.x
test "should not valid without name"
user = User.name :name => nil, :password => "senthil"
user.save
assert_valid(user)
end
Rails 3.x.x
test "should not valid without name"
user = User.name :name => nil, :password => "senthil"
user.save
assert(user.valid?) // for checking valid user
end
0 notes
Text
Alternate for < b> and < i> tag in HTML
Avoid using normal <b> and <i> tag in html page for better enhancement and some browser compatibility problem.
instead of <b> use <strong> tag and for <i> use <em> tag
<b> </b> => <strong> </strong>
<i> </i> => <em> </em>
0 notes
Text
Preventing Form Resubmission in Rails xx
Preventing Form Resubmission in Rails xx
application_controller.rb
def form_resubmission
ActiveSupport::SecureRandom.base64(32) # u can also use MD5 digest for this part.
end
View part which involves form submission
<% form_tag :action => "sample" do %>
<%= hidden_field_tag "my_form_csrf", form_resubmission %>
<%= text_field :form_1, :attr_1 %>
<%= text_field :form_2, :attr_2 %>
<%= submit_tag "Save" %>
<% end %>
sample_controller.rb
def sample
is_new_post = true
if (session[:csrf_token] == params[:my_form_csrf])
is_new_post = false
end
if (is_new_post)
# user coding .....
else
flash[:notice] = "Form already submitted"
redirect_to :back
end
end
0 notes
Text
Swaping two numbers in coffee script
Coffee Script Code
first_number = prompt("Enter first number to swap", "") second_number = prompt("Enter Second number to swap", "")
swap = (first_number, second_number) ->
temp = first_number first_number = second_number second_number = temp console.log (first_number) console.log (second_number)
swap first_number, second_number
Javascript complied code
var first_number, second_number, swap;
first_number = prompt("Enter first number to swap", "");
second_number = prompt("Enter Second number to swap", "");
swap = function(first_number, second_number) {
var temp;
temp = first_number;
first_number = second_number;
second_number = temp;
console.log(first_number);
return console.log(second_number);
};
swap(first_number, second_number);
1 note
·
View note
Text
Creating live application on Heroku with Rails 3.1.3
Create a new Rails application
rails new my_app -d mysql
Code the application with your own content,
..............................
.............................
Add following code in GemFile
gem 'execjs'
group :production do gem 'therubyracer', '~> 0.9.3.beta1' gem 'pg' end
Now run bundler without production
bundle install --without production
After this create heroku application along with stack using,
heroku create my_app --stack cedar
Now commit the code to heroku,
git push heroku master
Counting objects: 67, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (52/52), done.
Writing objects: 100% (67/67), 86.33 KiB, done.
Total 67 (delta 5), reused 0 (delta 0) '
-----> Heroku receiving push
-----> Rails app detected ------------------------------------------- ------------------------------------------- -------------------------------------------
0 notes
Text
Grape Gem
Create a rails application,
>> rails new basic_sample –d mysql
Change a directory to the basic sample
>> cd basic_sample
Add the grape gem into file, Gemfile gem "grape"
Install the following gem using bundle install
>> bundle install
Create a scaffold application for api creation,
>> rails g scaffold Article name:string description:string
Create an application database,
>> rake db:create
Migrating the application database into mysql
>> rake db:migrate
Create a api lib file into lib/api.rb
#lib/api.rb
module BasicSample
class API < Grape::API
prefix 'api'
resource 'entries' do
get do
Article.all
end
get ':id' do
Article.find(params[:id])
end
end
end
end
Add the following line into config/routes.rb
mount BasicSample::API => "/"
Add the following line at the top of config/routes.rb
require 'api'
For Checking the Configuration routing,
>> rake middleware
At last run server using,
>> rails s
Open up the browser and type the url for fetching api.
>> http://localhost:3000/api/articles
Finally We got the REST API Client.
0 notes
Text
Fixing Invalid gemspec. #
For fixing this type of error follow the following steps:
Invalid gemspec in [/usr/lib/ruby/gems/1.8/specifications/activemodel-3.2.0.rc1.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0xb664a594> 3.2.0.rc1"] Invalid gemspec in [/usr/lib/ruby/gems/1.8/specifications/tilt-1.3.3.gemspec]: invalid date format in specification: "2011-08-25 00:00:00.000000000Z" Invalid gemspec in [/usr/lib/ruby/gems/1.8/specifications/actionpack-3.2.0.rc1.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0xb668700c> 3.2.0.rc1"] Invalid gemspec in [/usr/lib/ruby/gems/1.8/specifications/json-1.6.1.gemspec]: invalid date format in specification: "2011-09-18 00:00:00.000000000Z" Invalid gemspec in [/usr/lib/ruby/gems/1.8/specifications/dm-serializer-1.2.1.gemspec]: invalid date format in specification: "2011-10-24 00:00:00.000000000Z" Invalid gemspec in [/usr/lib/ruby/gems/1.8/specifications/railties-3.2.0.rc1.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0xb66cc79c> 3.2.0.rc1"] Invalid gemspec in [/usr/lib/ruby/gems/1.8/specifications/json_pure-1.6.1.gemspec]: invalid date format in specification: "2011-09-18 00:00:00.000000000Z" 1.8.13
1) gem update --system
2) gem uninstall rails -v 3.2.0.rc1
3) remove the gemspec file which is located on [/usr/lib/ruby/gems/1.8/specifications/..]
0 notes
Text
Creating "Open with Scite" or "Open with Notepad" in context menu windows 7
OPEN WITH SCITE
Open regedit
HKEY_CLASSES_ROOT\*\shell
Create a new key named "Open with Scite"
Create a new key inside "Open with Scite" as "command"
Change the value of the key to "C:\bin\SciTE\SciTE.exe" "%1"
OPEN WITH NOTEPAD
Open regedit
HKEY_CLASSES_ROOT\*\shell
Create a new key named "Open with Scite"
Create a new key inside "Open with Scite" as "command"
Change the value of the key to "notepad.exe" "%1"
2 notes
·
View notes
Text
Rails 3.2.8 Installation Procedure
Installing Rails 3 for windows
· Download DEVKIT
· Extract the devkit into C:/
· Add the bin directory to the environment variable path
· Go to the C:/Devkit
· ruby dk.rb init
· ruby dk.rb review
· ruby dk.rb install
· gem install rails –include-dependencies
0 notes