File Uploading using Rails


Image Source: images.devshed.com

If you want your site visitor to upload a certain file on your server, Rails make it an easy task to undertake the requirement. We will use the new application of Ruby on Rails called upload. We can create the basic structure of the application. And we will need simple Rails commands. Start off with C:\ruby>rails upload, then decide if you’re going to save the uploaded file. Create the directory and then check permissions. Next thing to do is to create the controller and models. You can call helper function content_type to know media type of the uploaded file. Next is to open a file in write mode so we will be using open helper function which is provided by File object. The render function is to be used to redirect to view files and to display message. The last is to create a view file uploadfile.rhtml. Set the parameter to True so that the action will pass on the data properly.

Posted in Basics | Comments closed

A Complete Cross-Platform Application


Image Source:oreillynet.com

Ruby on Rails is a complete cross-platform application for web development. It is the best architecture for developing application programming. Ruby on Rails has several advantages over other frameworks. They are what makes Ruby development tasks fast and easy. It provides a meta programming method for the creation of databased web applications, which is known as, Scaffold. Using this you can easily construct templates and models needed for the majority of the basic websites, homepages and even web portals. “WEBrick” is a new technology which Ruby development uses too. The over-all sense of this, is that the library, included in the Ruby distribution, provides basic HTTP web server services and tools. Prototype, is another technological advancement which is part of the distribution also.

Posted in Programming | Tagged | Comments closed

Several Command-Line Options


Image Source: www.anylinuxwork.com

Here are some few command line options in which can guide you in programming your Ruby on Rails:

-0[octal}
The number “0” flag specifies the record separator character (\0, if no digit follows). -00 indicates paragraph mode: records are separated by two successive default record separator characters. -0777 reads the entire file at once (as it is an illegal character). Sets $/.

-a
‘Auto split mode when used with -n or -p; equivalent to executing {$F at the top of each loop iteration.

-C directory
Changes working directory to directory before executing.

-c
Checks syntax only; does not execute the program.
–copyright
Prints the copyright notice and exits.

-d, –debug
Sets $DEBUG to true. This can be used by your programs to enable additional tracing.

-e ‘command’
Executes command as one line of Ruby source. Several -e’s are allowed, and the commands are treated as multiple lines in the same program. If programfile is omitted when -e is present, execution stops after the -e commands have been run.

Posted in Advanced, Basics, Information, Medium, Programming, Sample Code, Set-Up | Comments closed

RoR and Text Editors Part-1

Though there is no preferred editor in the coding and editing of programs which is usually left to the programmer to decide. There are a couple of purpose built editors that can be used with RoR.

Emacs, has a quite simple configuration that accompanies its use and allows simultaneously displays changes as they are made hence it�s classification as a Display Editor. It also has a nifty help function the user can evoke by the simple press of the Ctrl-H keys. The Point feature allows the definition of the position of a character as they are entered onto the keyboard. The Echo Area Feature is a segment on the lower bottom of the screen editor that shows the amount of characters on the screen for various purposes should they be needed. The Mode Line is the last line on the screen which is signified by the starting and ending with dashes on the screen. Like all editors, Emacs has a menu bar where all the options available to the user can be found making use simpler instead of having to memorize special key combinations.

Posted in Basics | Comments closed

Before You Start

Assuming you have even just a little background in programming with any language there are four basic programs and extensions that you need but are provided by the quick installers you’ve just downloaded to your hard drive. You have The Ruby programming language program files, the Rails part of the programming extension/platform, MySql or your database query handling system and the Apache which is a web server that you use to emulate your application’s execution on the web. Granting you have these set up properly and tested (instructions for which are included in the installer package). You can now start building your first application with RoR.

Posted in Advanced, Basics, Medium, Set-Up | Tagged , , , | Comments closed

How Rails implements Ajax

aptanaradrails_thumb.jpg

When the browser displays the initial web page, different user actions cause it to display a new web page or prompt an Ajax operation:

1.A trigger action occurs and this could be because of the user clicking on a link or button or the user making changes to the information on a form in a field or just an interrupted activation.
2.Data linked with the trigger is sent to an action handler on the server through XMLHttpRequest.
3.The server-side action handler takes some action basing on the data and returns with a response, an HTML fragment.
4.The client-side Javascript accepts the HTML fragment and uses it to update a particular portion of the current page’s HTML, often the content of a

tag.

Posted in Basics | Tagged , | Comments closed

Ruby Central

top_diamond.jpg

Ruby Central Inc. is a non-profit organization based in the United States that is committed to support and for the advocacy and promotion of the Ruby programming language. This organization was founded and established by a group of Ruby advocates like David Alan Black, Richard Kilmer and Chad Fowler. Ruby central is the parent of the annual International Ruby and Ruby on Rails Conferences that serves as a presence and contact point of corporate sponsors concerned in supporting and promotion theses conferences and other Ruby activities. Its first project was RubyConf 2002 and ever since, RubyConf’s have been held. Teaming up with the San Francisco-based Software Development Forum to produce the 2006 Silicon Valley Ruby Conference, Ruby central has also become a center for support of Ruby activities.

Posted in Basics | Tagged | Comments closed

Rails web server

starting_rails1.jpg

If Mongrel and lighttpd are not installed, by default Rails will use WEBrick, the webserver that ships with Ruby. All these will guarantee you to always get up and run promptly. Rails will check first if Mongrel exists when you run script/server, then check on lighttpd and would finally fall back to WEBrick which is a small Ruby web server appropriate for development but not for production. Mongrel is a Ruby-based webserver possessing a C component that requires compilation. It is suitable for development and operation of Rails application. Lighttpd is considerably faster than MOngerl and WEBrick but entails additional installation and presently only works well on OS X/Unix.

Posted in Basics, Programming | Tagged , , , | Comments closed

Ruby on Rails: Web Development on Mac OS X

pgadmin.jpg

Ruby on Rails with its noteworthy benefits and real-world applications in production made its web application framework a top choice. And it is not a shocker for Rails to succeed on the abundance of Mac OS X. Ruby on Rails is an open source tool that quickly generates great web applications backed up by SQL databases to keep up with the speed of the web. Members of the Rails core development team work with Mac. A prominent text editor used by Rails programmers is a Cocoa application called TextMate. That is why it is not much of a revelation that Mac OS X has been a preferential application for Rails’ expansion and development.

Posted in Basics | Tagged , | Comments closed

Rails technicality

rails11.jpg

Rails uses the Model-View-Controller (MVC) architecture just like many other contemporary web frameworks for organizing application programming. Rails is remarkable for its widespread use of the JavaScript libraries Prototype and Script.aculo.us that is significantly used for for Ajax and its graphical interface. And because of Rails’ “out of the box” scaffolding, it can promptly generate most of the models and views necessary for a basic website. Rails has useful development tools built in or already installed like the WEBrick web server and the Rake build system. Rails also originally supported lightweight SOAP for web services and it was later replaced by RESTful web services as it significantly altered to version 1.2.

Posted in Basics | Tagged , | Comments closed

Bad Behavior has blocked 14 access attempts in the last 7 days.