Search

Categories

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Send mail to the author(s) E-mail

# Friday, April 30, 2010
( Tools )

Bug/Issue Trackers

Confluence / Jira issue

Fogbugz

 

Mocking:

balsamiq – integrates into confluence/jira/fogbugz

 image

Screen Capture in WinXP - cropper

Comments [0] | | # 

I’m using a Windows2008 shared server there.

When I go

http://cmstest.mateerit.co.nz/sitefinity/admin/pages.aspx?select=6bfb28b5-8858-40e0-b41c-c4de7377dc25&action=saved

2010-04-25 02:28:11 W3SVC3267 WINPLESK8 119.47.118.16 GET /Rejected-By-UrlScan ~/sitefinity/admin/pages.aspx?select=6bfb28b5-8858-40e0-b41c-c4de7377dc25 80 - 118.90.119.91 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-GB;+rv:1.9.2.3)+Gecko/20100401+Firefox/3.6.3 .ASPNET=1AFB9766977A21A55E7B9BAF3F27FCCD8DAF9A049A7845DD4405823A6777D6E80FE4233EF6C403BEAAEA4E0E981AAD087B225606D56470A932DD82D59DDDD76DD0AF4C5BCB1A3ACCAD31BB26B8541EB84B1602F1834AC23A72327049A436D1C2;+ASP.NET_SessionId=mbucdi45fpa5ee55bddc5qy0;+.ASPXROLES=ipJFW4T_cJvPAYLQ5ZPJt3W3ZvEDmRcZaR65fdIMjQk4lclLmuzIb0-8SdEZtVinSUlefJlWwobKC3KhexUfFinsek_a-SavHnIQ2LZneONdBBZFDAxeSURWQiBvbIDY1WVktLDKeaYMpC5q1i36pGdXFoWZRAe_jSDPSPDqvCVLPma-BCUAq5dYtyFnHdgIYhKIg39XxHJvRao8sseVFm5DJLi0GSSGoEp4vgMh5EeK1KmgR0-pXiYTB5j4Rcap18QBjA2d8Bexcwr_Iugw41jm-ph9SCspbunO0ws1X6IC9ejiCCB5AydiKsKsYYQhcnLcXIOzFSspfOOYmm3RF1v6TnVv9xytzJzn14NP5Dh-h_wRYnWXbpM_hyfDTiVBEEvu1yFC6HMMD-PQ2BH_FzJ0SmWxKIoikslK6EG41KrFfwrcaRWyBDxkWoddsgVF0 http://cmstest.mateerit.co.nz/sitefinity/admin/Pages.aspx cmstest.mateerit.co.nz 404 0 2 1218 1231 468

So it looks like a Rejected-By-UrlScan issue

URLScan is configured to reject certain requests. URLScan.ini

Another email to my providers openhost.co.nz who turned off URLScan for me.

Comments [0] | | # 

http://www.sourcegear.com/fortress/

An Application Lifecycle Management tool.

Version Control based on Vault.

Work Item Tracking

Admin Web Front End:

image

There is a repo front end

image

VS Integration (Work Item Tracking)

image

http://support.sourcegear.com/

How to Add a Solution into Source Control

Make sure VS knows about Fortress:

image

Right click solution file in VS and do add to

image

Easy to add in files and see diffs within VS.

image

Doing a change to a file which is in source control (page2).

Working With Tasks

image

Here I am checking in some code against a feature request.

image

Something which I find confusing is why are there 2 unresolved tasks in ‘Get bones of the site working’, and I click on them and it shows:

image

Here the status of the tasks are both Completed.

 

Overall I get what it is doing, and am about to use it for real in a project now.

Comments [0] | | # 
# Thursday, April 22, 2010
( Tools )

Have heard a lot about this, so am trying it out:

image

can specify the dimensions of the page eg 1024.

link bar.

 

first try of mocking up.. ok so paid the license which was super easy.  And within 2 hours I’d sent off the mockups I wanted to my project collaborator.

Comments [0] | | # 
# Thursday, April 15, 2010
( Tools )

image

Tools, Options.. Always show solution :-)

Comments [0] | | # 
# Thursday, April 08, 2010

The last week of looking at RoR:

  • Does all the plumbing if you follow the convention
  • Amazing how little code you need to write
  • The important stuff for CRUD apps is all there – validators, db relationships, CRUD functionality
  • The ORM works
  • Fast to develop!

In summary this look like a wonderful technology for putting together CRUD based business apps fast.

Shared hosting seems to be harder than .NET / PHP, however heroku.com is a great free resource.

Commercially speaking I think it would work very well in an enterprise where there is a need to develop apps fast (when isn’t there!) that do not require huge performance (I would argue that most apps I’ve worked on would be well suited in RoR).

Comments [0] | | # 
# Wednesday, April 07, 2010

ruby script/generate scaffold flight departure:datetime arrival:datetime destination:string baggage_allowance:decimal capacity:integer

ruby script/generate scaffold seat flight_id:integer name:string baggage:decimal

rake db:migrate

image

 

image

What we want is a form that has the flight info on it, then the ability to add a new seat booking.

Partials

Coppied seat/new.html.erb  into flight/show.html.erb file rendering as a partial

_new_seat.html.erb

Changed:

<% form_for(seat) do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :flight_id %><br />
    <%= f.text_field :flight_id %>
  </p>
  <p>
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :baggage %><br />
    <%= f.text_field :baggage %>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

the form_for(@seat) to (seat) to become a local variable to the partial.  This is good practise.

called the partial from flights/show.html.erb as

<%= render :partial=>"new_seat", :locals=>{:seat=>Seat.new(:flight_id=>@flight.id)}%>

<% form_for(seat) do |f| %>
  <%= f.error_messages %>
  <%= f.hidden_field :flight_id %>

image

We also need a partial for the seat list

image

however this is bad as its displaying the seats for all flights

Connect the models together

means we don’t need to use finders.. it works automatically.

class Flight < ActiveRecord::Base
  has_many :seats
end

then when rendering out the listing of seats we can pass in the array  in show.html.erb

<%= render :partial=>"seat_list", :locals=>{:seats=> @flight.seats}%>

in the model:

belongs_to :flight
    def validate
        if baggage > Flight.find(flight_id).baggage_allowance
            errors.add_to_base("You have too much baggage")
        end
        if flight.seats.size >= flight.capacity
            errors.add_to_base("The flight is fully booked")
        end
    end

image

another custom validator in the seat model

if flight.seats.size >= flight.capacity
            errors.add_to_base("The flight is fully booked")
        end

image

**TO DO put in a validator that checks there is a number for baggage

Comments [0] | | # 

ruby script/generate scaffold client_workout client_name:string trainer:string duration_mins:integer date_of_workout:date paid_amount:decimal

rake db:migrate

Problem is that the scaffolding app doesn’t do exactly what we want.

image

what we want is just the listing for Lenny Goldberg ie a filter.

Creating a Form with no Model

instead of form_for

<% form_for(@ad,:url=>{:action=>'update'}) do |f| %>
  <p><b>Name</b><br /><%= f.text_field :name %></p>
  <p><b>Description</b><br /><%= f.text_area :description %></p>
  <p><b>Price</b><br /><%= f.text_field :price %></p>
  <p><b>Seller</b><br /><%= f.text_field :seller_id %></p>
  <p><b>Email</b><br /><%= f.text_field :email %></p>
  <p><b>Img url</b><br /><%= f.text_field :img_url %></p>
  <p><%= f.submit "Update" %></p>
<% end %>

we use form_tag

<% form_tag "/client_workouts/find" do%>
      <%= text_field_tag :search_string%>
      <%= submit_tag "Search" %>
    <% end %>

 

image

image

by putting in dave into the search box, we can see it coming through in the controller by using puts to output to the console.

So we only need those records where client_name = the search string.

def find
      puts params[:search_string]
      @client_workouts = ClientWorkout.find_all_by_client_name(params[:search_string])
  end

The framework creates finders for each attribute.. eg find_all_by_client_name.

and I just wired up to a find.html.erb file.

image

however we want to search on trainer as well ie where client_name=”Lenny Goldbery” or trainer = “Lenny Goldberg”

@client_workouts = ClientWorkout.find(:all, :conditions=>["client_name = ? OR trainer = ?",
                          params[:search_string], params[:search_string]])

image

The crowd goes wild!  Can filter on client_name or trainer.

Validators

A number:

class ClientWorkout < ActiveRecord::Base
    validates_numericality_of :paid_amount
end

Mandatory:

class ClientWorkout < ActiveRecord::Base
    validates_numericality_of :paid_amount
    validates_presence_of :trainer
    validates_presence_of :client_name
end

image

 

Doing it on custom code:

class Ad < ActiveRecord::Base
  validates_presence_of :price
  validates_presence_of :name
end

def create
      @ad = Ad.new(params[:ad])
      if @ad.save
        redirect_to "/ads/#{@ad.id}"
      else
        render :template => "ads/new"
      end
  end

<% form_for(@ad,:url=>{:action=>'create'}) do |f| %>
    <%=f.error_messages%>

image

Comments [0] | | # 

here is how we do it from scaffolding:

Symbols and Strings

<%= f.label :seat_id_seq %>   This is a symbol.  They always start with a colon.  Generally used to name things.  Mostly interchangeable with strings.

<%= f.label “Seat #” %>   This is a string.

Add a column to the DB

to add the database we:

ruby script/generate scaffold ticket name:string seat_id_seq:string address:text price_paid:decimal email_address:string

to add a row:

ruby script/generate migration AddPhoneToTickets phone:string

important bit is Add…To…

then

rake db:migrate

image

then changed the 4 view to display the new field.

Starting From Scratch

The scaffolding can create too much code!  Here is an app just generating 1 page to start with (a show page)

ruby script/generate model ad name:string description:text price:decimal seller_id:integer email:string img_url:string

models have singular names eg ticket, ad

Controller

ruby script/generate controller ads

controllers have plural names

Routes

map.connect '/ads/:id', :controller=>'ads', :action=>'show'

use the ads_controller.rb, and the show template.

View

show.html.erb

<p>
    <b>Name:</b><%= @ad.name %>
</p>

image

Index Page

controller:

  def index
    @ads = Ad.find(:all)
  end

index.html.erb

<% for ad in @ads%>
    <li><a href="/ads/<%= ad.id%>"><%=ad.name%></a></li>
<% end %>

route

map.connect 'ads/', :controller=>'ads', :action=>'index'

image

Layouts

images into public/images

stylesheet into public/stylesheets

apps/views/layouts/ads.html.erb

image

Post New Ads Online

routes

map.connect 'ads/new', :controller=>'ads', :action=>'new'
map.connect 'ads/create', :controller=>'ads', :action=>'create'

viewff

 

ads/new.html.erb

and the form will be submitted to:

ads/create

 

RoR Text Editor

Am trying http://www.e-texteditor.com/

ctrl shift p – toggle between project view and editor view

http://www.e-texteditor.com/wiki/index.php/Projects#Keyboard_navigation – keyboard shortcuts

Create Form Helper

Rails can create forms that are associated with model objects. so in new.html.erb

<% form_for(@ad,:url=>{:action=>'create'}) do |f| %>
  <p><b>Name</b><br /><%= f.text_field :name %></p>
  <p><b>Description</b><br /><%= f.text_area :description %></p>
  <p><b>Price</b><br /><%= f.text_field :price %></p>
  <p><b>Seller</b><br /><%= f.text_field :seller_id %></p>
  <p><b>Email</b><br /><%= f.text_field :email %></p>
  <p><b>Img url</b><br /><%= f.text_field :img_url %></p>
  <p><%= f.submit "Create" %></p>
<% end %>

eg this comes out as:

<b>Name</b><br /><input id="ad_name" name="ad[name]" size="30" type="text" />
image 

so when the submit button is pressed, this routes back to the create action in the AdsController.

Controller

def new
      @ad = Ad.new   
  end


  def create
      @ad = Ad.new(params[:ad])
      @ad.save
      redirect_to "/ads/#{@ad.id}"
  end

note:  create an empty ad object before passing onto new

and we have an automatic redirect to the listing

otherwise could have commented out and it would go automatically to create.html.erb:

image

Edit a Record

routes add in

map.connect 'ads/:id/edit', :controller=>'ads', :action=>'edit'
map.connect 'ads/:id/update', :controller=>'ads', :action=>'update'

controller add in

def edit
      @ad = Ad.find(params[:id])
  end
  def update
      @ad = Ad.find(params[:id])
      @ad.update_attributes(params[:ad])
      redirect_to"/ads/#{@ad.id}"
  end

view add in

<% form_for(@ad,:url=>{:action=>'update'}) do |f| %>
  <p><b>Name</b><br /><%= f.text_field :name %></p>
  <p><b>Description</b><br /><%= f.text_area :description %></p>
  <p><b>Price</b><br /><%= f.text_field :price %></p>
  <p><b>Seller</b><br /><%= f.text_field :seller_id %></p>
  <p><b>Email</b><br /><%= f.text_field :email %></p>
  <p><b>Img url</b><br /><%= f.text_field :img_url %></p>
  <p><%= f.submit "Update" %></p>
<% end %>

Security

in the AdsController

before_filter :check_logged_in, :only => [:edit, :update]

  private
    def check_logged_in
        authenticate_or_request_with_http_basic("Ads") do |username, password|
            username == "admin" && password == "secret"
        end
    end

image

 

Delete

image

Just calling a single action on the controller called destory which then redirects back to index.

 

**TODO put this live

Comments [0] | | # 
# Thursday, April 01, 2010

elevator

use cases

paper prototype:

put mock up live

http://pubtricks.heroku.com/

image

changes to scaffold:

background colour in all games in \views\layouts\games.html.erb

Comments [0] | | #