This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count = 0 | |
a = Dir.glob("/<rails app path>/app/models/**/*.rb") | |
a.each do |f| | |
file = File.new(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Following is the problem with your solution. You have 2 if's , in ruby we need only 1 if | |
# notice that it has only one IF :) | |
if matched_games.length > 0 && matched_games.include?(search) | |
puts "Game #{search} found." | |
end | |
#clarrifications | |
Regexp.new(search) #is creating a new regular expression object in ruby. | |
#<Any Object>.new is the way of initializing an object in ruby. In this case 'Regexp' class. | |
#Regular expression can me used to match words in different options. Like |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== Managing the database in a Rails application === |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== Rails migrations === | |
In ruby/rails projects , the standard way of hadling database changes (add/edit tables, add/edit columns etc..) | |
through the migrations. this way we can hadle database changes easily. | |
=== where are the migrations === | |
migrations are in the following folder | |
```ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ItemsController < ApplicationController | |
#rest of your methods | |
# ...... | |
private | |
def item_params | |
params.require(:item).permit( | |
:name, | |
:content, | |
:image, | |
:address, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// link <a title="recipe" href="sampleapp://recipes/3">recipe</a> | |
//app.js | |
function handleOpenURL(url) { | |
setTimeout(function() { | |
window.location.hash = '/app/show/' + url.split("/").pop(); | |
}, 500); | |
} | |
// following is my router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:javascript | |
Event.observe(window,'load',function(){ | |
instantiateCkEditor('#{page_part.name.downcase}') | |
Event.addBehavior({ 'a.insert_asset': InsertIntoCk }) | |
}) | |
Event.observe($('part_#{page_part.name.downcase}_filter_id'),'change',function(){ toggleEditor('#{page_part.name.downcase}') }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:javascript | |
Event.observe(window,'load',function(){ | |
instantiateCkEditor('#{page_part.name.downcase}') | |
Event.addBehavior({ 'a.insert_asset': InsertIntoCk }) | |
}) | |
Event.observe($('part_#{page_part.name.downcase}_filter_id'),'change',function(){ toggleEditor('#{page_part.name.downcase}') }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in *.erb; do mv "$i" "`basename $i .erb`.erb.old"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Treatment | |
has_many :treatment_treatment_types | |
has_many :treatment_types, :through => :treatment_treatment_types | |
end | |
class TreatmentTypes | |
has_many :treatment_treatment_types | |
has_many :treatments, :through => :treatment_treatment_types | |
end |
OlderNewer