Search Results

Search found 22 results on 1 pages for 'inflector'.

Page 1/1 | 1 

  • Inflector for .NET

    - by srkirkland
    I was writing conventions for FluentNHibernate the other day and I ran into the need to pluralize a given string and immediately thought of the ruby on rails Inflector.  It turns out there is a .NET library out there also capable of doing word inflection, originally written (I believe) by Andrew Peters, though the link I had no longer works.  The entire Inflector class is only a little over 200 lines long and can be easily included into any project, and contains the Pluralize() method along with a few other helpful methods (like Singularize(), Camelize(), Capitalize(), etc). The Inflector class is available in its entirety from my github repository https://github.com/srkirkland/Inflector.  In addition to the Inflector.cs class I added tests for every single method available so you can gain an understanding of what each method does.  Also, if you are wondering about a specific test case feel free to fork my project and add your own test cases to ensure Inflector does what you expect. Here is an example of some test cases for pluralize: TestData.Add("quiz", "quizzes"); TestData.Add("perspective", "perspectives"); TestData.Add("ox", "oxen"); TestData.Add("buffalo", "buffaloes"); TestData.Add("tomato", "tomatoes"); TestData.Add("dwarf", "dwarves"); TestData.Add("elf", "elves"); TestData.Add("mouse", "mice");   TestData.Add("octopus", "octopi"); TestData.Add("vertex", "vertices"); TestData.Add("matrix", "matrices");   TestData.Add("rice", "rice"); TestData.Add("shoe", "shoes"); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Pretty smart stuff.

    Read the article

  • Where is the appropriate place to define inflector rules in CakePHP 1.3?

    - by Daniel Wright
    In CakePHP 1.2, custom inflector rules could be defined in a file app/config/inflections.php. This file was removed in CakePHP 1.3. Instead, the documentation prescribes using the Inflector::rules function to load custom inflections. There's adequate documentation of how to define the custom inflections themselves, but the documentation gives no context—where to use Inflector::rules. Should any custom inflections be defined in the bootstrap.php script? At the top of applicable corresponding controllers? Somewhere else? See also: Configuration: Inflections in the documentation Inflector::rules definition in the API documentation

    Read the article

  • Where is it appropriate to define inflector rules in CakePHP 1.3?

    - by Daniel Wright
    In CakePHP 1.2, custom inflector rules could be defined in a file app/config/inflections.php. This file was removed in CakePHP 1.3. Instead, the documentation prescribes using the Inflector::rules function to load custom inflections. There's adequate documentation of how to define the custom inflections themselves, but the documentation gives no context—where to use Inflector::rules. Should any custom inflections be defined in the bootstrap.php script? At the top of applicable corresponding controllers? Somewhere else? See also: Configuration: Inflections in the documentation Inflector::rules definition in the API documentation

    Read the article

  • Inflector::humanize($key) converts Date of joining TO Date Of Joining

    - by Aruna
    Hi, I have a Form and i am submitting them like using function submit($formid = null,$fillerid=null) { $this->data['Result']['form_id']=$formid; $this->data['Result']['submitter_id']=$fillerid; $this->data['Result']['submitter']=$this->Session->read('filler'); echo "submitter: ".$this->Session->read('filler'); $results=$this->Form->hasResults($this->data); //echo http_build_query($_POST); if(empty($results)){ foreach ($_POST as $key => $value): if(is_array($value)){ $value = implode('', $_POST[$key]); $this->data['Result']['value']=$value; } else{ $this->data['Result']['value']=$value; } $this->data['Result']['form_id']=$formid; $this->data['Result']['submitter_id']=$fillerid; $this->data['Result']['label']=Inflector::humanize($key); $this->data['Result']['submitter']=$this->Session->read('filler'); $this->Form->submitForm($this->data); endforeach; $this->Session->setFlash('Your entry has been submitted.'); } I am having A fORM LIKE <form method="post" action="/FormBuilder/index.php/forms/submit/1/4" id="ResultSubmit"> <div class="input text"><label for="1">Firstname</label><input type="text" value="" style="width: 300px;" id="1" name="Firstname"/></div> <br/> <div class="input text"><label for="2">Last Name</label><input type="text" value="" style="width: 300px;" id="2" name="Last Name"/></div> <br/> <div class="input text"><label for="3">Age</label><input type="text" value="" style="width: 200px;" id="3" name="Age"/></div> <br/> <center> <span id="errmsg3"/> </center> <div class="input textarea"><label for="4">Address</label><textarea style="height: 300px;" id="4" rows="6" cols="30" name="Address"/></div> <br/> <div class="input text"><label for="5">Date Of Joining</label><input type="text" value="" style="width: 300px;" id="5" name="Date of joining"/></div><br/> <div class="input text"><label for="6">Email - Id</label><input type="text" value="" style="width: 300px;" id="6" name="Email - id"/></div> <br/> <div class="input text"> <label for="7">Personal Number</label><input type="text" value="" maxlength="3" style="width: 30px;" id="7" name="Personal Number[]"/><input type="text" value="" style="width: 30px;" maxlength="3" id="7-1" name="Personal Number[]"/><input type="text" value="" style="width: 70px;" maxlength="4" id="7-2" name="Personal Number[]"/></div> <span id="errmsg7"/> <br/> <div class="input select"><label for="8">Gender</label><select id="8" name="Gender"> MaleFemale <div class="input text"><label for="9">Official Number</label><input type="text" value="" style="width: 200px;" id="9" name="Official Number"/></div><br/> <div class="input select"><label for="10">Experience</label><select id="10" name="Experience"> <option value="Fresher">Fresher</option><option yrs="" 5="" value="Below">Below 5 Yrs</option><option yrs="" 10="" value="Above">Above 10 yrs</option></select></div><br/> actually My input has the names as Firstname Last Name Age Address Date of joining Email - id Personal Number Gender Official Number But when i use Inflector::humanize($key) for saving the names which has white space characters they have converted into like Date Of Joining i.e.., O and J becomes Capital letters... But i need to save them as such as Date of joining.. How to do so???

    Read the article

  • problem with uninitialized constant

    - by VinTem
    Hi, I have the following controller class ActiveUsersController < ApplicationController def edit end end And my routes.rb is like this: map.resources :active_users When I try to access the controller using the url http://localhost:3000/active_users/COo8e45RqQAHr6CqSCoI/edit I got the following error: NameError in Active usersController#edit uninitialized constant ActiveUsersController RAILS_ROOT: /Users/vintem/Documents/Projetos/Pessoal/bugfreela Application Trace | Framework Trace | Full Trace /Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in load_missing_constant' /Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:inconst_missing' /Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in const_missing' /Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:inconstantize' /Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in each' /Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:inconstantize' /Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in constantize' /Users/vintem/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:443:inrecognize' /Users/vintem/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:436:in `call' Can anyone help me? Thanks

    Read the article

  • Gitorious errors

    - by Switz
    I installed Gitorious on my (shared) hosting. I was getting errors, but I seemed to have fixed most of them. It is working. When I commit/push, I get a lot of remote: errors spewed out although it does push the files properly from what I can tell. Here are the errors I'm getting (I swapped out the domain to git.domain.com): $ git push origin master Counting objects: 5, done. Delta compression using up to 2 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 283 bytes, done. Total 3 (delta 2), reused 0 (delta 0) remote: /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/inflector.rb:361:in `const_defined?': wrong constant name Admin/usersHelper (NameError) remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/inflector.rb:361:in `constantize' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/inflector.rb:360:in `each' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/inflector.rb:360:in `constantize' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb:162:in `constantize' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/actionpack/lib/action_controller/helpers.rb:137:in `helper' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/actionpack/lib/action_controller/helpers.rb:115:in `each' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/actionpack/lib/action_controller/helpers.rb:115:in `helper' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/actionpack/lib/action_controller/helpers.rb:120:in `helper' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/actionpack/lib/action_controller/helpers.rb:115:in `each' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/actionpack/lib/action_controller/helpers.rb:115:in `helper' remote: from /home/saegit/GIT.DOMAIN.COM/app/controllers/searches_controller.rb:22 remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/dependencies.rb:265:in `require_or_load' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/dependencies.rb:224:in `depend_on' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/activesupport/lib/active_support/dependencies.rb:136:in `require_dependency' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/railties/lib/initializer.rb:414:in `load_application_classes' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/railties/lib/initializer.rb:413:in `each' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/railties/lib/initializer.rb:413:in `load_application_classes' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/railties/lib/initializer.rb:411:in `each' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/railties/lib/initializer.rb:411:in `load_application_classes' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/railties/lib/initializer.rb:197:in `process' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/railties/lib/initializer.rb:113:in `send' remote: from /home/saegit/GIT.DOMAIN.COM/vendor/rails/railties/lib/initializer.rb:113:in `run' remote: from /home/saegit/GIT.DOMAIN.COM/config/environment.rb:24 remote: from /home/saegit/GIT.DOMAIN.COM/lib/gitorious/messaging/sync_adapter.rb:27:in `require' remote: from /home/saegit/GIT.DOMAIN.COM/lib/gitorious/messaging/sync_adapter.rb:27:in `load_env' remote: from /home/saegit/GIT.DOMAIN.COM/lib/gitorious/messaging/sync_adapter.rb:31:in `load_processor' remote: from /home/saegit/GIT.DOMAIN.COM/lib/gitorious/messaging/sync_adapter.rb:55:in `queue' remote: from /home/saegit/GIT.DOMAIN.COM/lib/gitorious/messaging/sync_adapter.rb:59:in `do_publish' remote: from /home/saegit/GIT.DOMAIN.COM/lib/gitorious/messaging.rb:39:in `publish' remote: from ./hooks/messaging.rb:45:in `post_message' remote: from hooks/post-receive:37 remote: => Syncing Gitorious... To [email protected]:os/ptd.git 7526ccb..3316eb2 master -> master

    Read the article

  • Linking LLVM JIT Code to Static LLVM Libraries?

    - by inflector
    I'm in the process of implementing a cross-platform (Mac OS X, Windows, and Linux) application which will do lots of CPU intensive analysis of financial data. The bulk of the analysis engine will be written in C++ for speed reasons, with a user-accessible scripting engine interfacing with the C++ testing engine. I want to write several scripting front-ends over time to emulate other popular software with existing large user bases. The first front will be a VisualBasic-like scripting language. I'm thinking that LLVM would be perfect for my needs. Performance is very important because of the sheer amount of data; it can take hours or days to run a single run of tests to get an answer. I believe that using LLVM will also allow me to use a single back-end solution while I implement different front-ends for different flavors of the scripting language over time. The testing engine itself will be separated from the interface and testing will even take place in a separate process with progress and results being reported to the testing management interface. Tests will consist of scripting code integrated with the testing engine code. In a previous implementation of a similar commercial testing system I wrote, I built a fast interpreter which easily interfaced with the testing library because it was written in C++ and linked directly to the testing engine library. Callbacks from scripting code to testing library objects involved translating between the formats with significant overhead. I'm imagining that with LLVM, I could implement the callbacks into C++ directly so that I could make the scripting code work almost as if it had been written in C++. Likewise, if all the code was compiled to LLVM byte-code format, it seems like the LLVM optimizers could optimize across the boundaries between the scripting language and the testing engine code that was written in C++. I don't want to have to compile the testing engine every time. Ideally, I'd like to JIT compile only the scripting code. For small tests, I'd skip some optimization passes, while for large tests, I'd perform full optimizations during the link. So is this possible? Can I precompile the testing engine to a .o object file or .a library file and then link in the scripting code using the JIT? Finally, ideally, I'd like to have the scripting code implement specific methods as subclasses for a specific C++ class. So the C++ testing engine would only see C++ objects while the JIT setup code compiled scripting code that implemented some of the methods for the objects. It seems that if I used the right name mangling algorithm it would be relatively easy to set up the LLVM generation for the scripting language to look like a C++ method call which could then be linked into the testing engine. Thus the linking stage would go in two directions, calls from the scripting language into the testing engine objects to retrieve pricing information and test state information and calls from the testing engine of methods of some particular C++ objects where the code was supplied not from C++ but from the scripting language. In summary: 1) Can I link in precompiled (either .bc, .o, or .a) files as part of the JIT compilation, code-generation process? 2) Can I link in code using that the process in 1) above in such a way that I am able to create code that acts as if it was all written in C++?

    Read the article

  • uninitialized constant Active Scaffold rails 2.3.5

    - by Kiva
    Hi guy, I update my rails application 2.0.2 to 2.3.5. I use active scaffold for the administration part. I change nothing in my code but a problem is coming with the update. I have a controller 'admin/user_controller' to manage users. Here is the code of the controller: class Admin::UserController < ApplicationController layout 'admin' active_scaffold :user do |config| config.columns.exclude :content, :historique_content, :user_has_objet, :user_has_arme, :user_has_entrainement, :user_has_mission, :mp, :pvp, :user_salt, :tchat, :notoriete_by_pvp, :invitation config.list.columns = [:user_login, :user_niveau, :user_mail, :user_bloc, :user_valide, :group_id] #:user_description, :race, :group, :user_lastvisited, :user_nextaction, :user_combats_gagner, :user_combats_perdu, :user_combats_nul, :user_password, :user_salt, :user_combats, :user_experience, :user_mana, :user_vie config.create.link.page = true config.update.link.page = true config.create.columns.add :password, :password_confirmation config.update.columns.add :password, :password_confirmation config.create.columns.exclude :user_password, :user_salt config.update.columns.exclude :user_password, :user_salt config.list.sorting = {:user_login => 'ASC'} config.subform.columns = [] end end This code hasn't change with the update, but when I go in this page, I got this error: uninitialized constant Users /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in `constantize' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `constantize' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in `constantize' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:28:in `reverse_matches_for' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `reverse_matches_for' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:11:in `reverse' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb:117:in `autolink?' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:107:in `links_for_associations' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:106:in `links_for_associations' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:59:in `active_scaffold' /Users/Kiva/Documents/Projet-rpg/jeu/app/controllers/admin/user_controller.rb:11 I search since 2 days but I don't find the problem, can you help me please.

    Read the article

  • uninitialized constant Active Scaffold rails 2.3.5

    - by Kiva
    Hi guy, I update my rails application 2.0.2 to 2.3.5. I use active scaffold for the administration part. I change nothing in my code but a problem is coming with the update. I have a controller 'admin/user_controller' to manage users. Here is the code of the controller: class Admin::UserController < ApplicationController layout 'admin' active_scaffold :user do |config| config.columns.exclude :content, :historique_content, :user_has_objet, :user_has_arme, :user_has_entrainement, :user_has_mission, :mp, :pvp, :user_salt, :tchat, :notoriete_by_pvp, :invitation config.list.columns = [:user_login, :user_niveau, :user_mail, :user_bloc, :user_valide, :group_id] #:user_description, :race, :group, :user_lastvisited, :user_nextaction, :user_combats_gagner, :user_combats_perdu, :user_combats_nul, :user_password, :user_salt, :user_combats, :user_experience, :user_mana, :user_vie config.create.link.page = true config.update.link.page = true config.create.columns.add :password, :password_confirmation config.update.columns.add :password, :password_confirmation config.create.columns.exclude :user_password, :user_salt config.update.columns.exclude :user_password, :user_salt config.list.sorting = {:user_login => 'ASC'} config.subform.columns = [] end end This code hasn't change with the update, but when I go in this page, I got this error: uninitialized constant Users /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in `constantize' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `constantize' /Users/Kiva/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in `constantize' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:28:in `reverse_matches_for' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:24:in `reverse_matches_for' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb:11:in `reverse' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb:117:in `autolink?' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:107:in `links_for_associations' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb:62:in `each' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:106:in `links_for_associations' /Users/Kiva/Documents/Projet-rpg/jeu/vendor/plugins/active_scaffold/lib/active_scaffold.rb:59:in `active_scaffold' /Users/Kiva/Documents/Projet-rpg/jeu/app/controllers/admin/user_controller.rb:11 I search since 2 days but I don't find the problem, can you help me please.

    Read the article

  • Fluent NHibernate SchemaExport to SQLite not pluralizing Table Names

    - by weenet
    I am using SQLite as my db during development, and I want to postpone actually creating a final database until my domains are fully mapped. So I have this in my Global.asax.cs file: private void InitializeNHibernateSession() { Configuration cfg = NHibernateSession.Init( webSessionStorage, new [] { Server.MapPath("~/bin/MyNamespace.Data.dll") }, new AutoPersistenceModelGenerator().Generate(), Server.MapPath("~/NHibernate.config")); if (ConfigurationManager.AppSettings["DbGen"] == "true") { var export = new SchemaExport(cfg); export.Execute(true, true, false, NHibernateSession.Current.Connection, File.CreateText(@"DDL.sql")); } } The AutoPersistenceModelGenerator hooks up the various conventions, including a TableNameConvention like so: public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance) { instance.Table(Inflector.Net.Inflector.Pluralize(instance.EntityType.Name)); } This is working nicely execpt that the sqlite db generated does not have pluralized table names. Any idea what I'm missing? Thanks.

    Read the article

  • SQLite not pluralizing Table Names

    - by weenet
    I am using SQLite as my db during development, and I want to postpone actually creating a final database until my domains are fully mapped. So I have this in my Global.asax.cs file: private void InitializeNHibernateSession() { Configuration cfg = NHibernateSession.Init( webSessionStorage, new [] { Server.MapPath("~/bin/MyNamespace.Data.dll") }, new AutoPersistenceModelGenerator().Generate(), Server.MapPath("~/NHibernate.config")); if (ConfigurationManager.AppSettings["DbGen"] == "true") { var export = new SchemaExport(cfg); export.Execute(true, true, false, NHibernateSession.Current.Connection, File.CreateText(@"DDL.sql")); } } The AutoPersistenceModelGenerator hooks up the various conventions, including a TableNameConvention like so: public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance) { instance.Table(Inflector.Net.Inflector.Pluralize(instance.EntityType.Name)); } This is working nicely execpt that the sqlite db generated does not have pluralized table names. Any idea what I'm missing? Thanks.

    Read the article

  • RAils Authlogic and Hobo

    - by MrThomas
    Is there anyone out there who has an idea of how to incorporate Hobo as an admin subsite on a existing rails app running on authlogic. I've been following this tutorial, but it not working. Any help or Tutorial link please! Some erorr code for anyone who fancies a crack: ~/dev/copy> ./script/server => Booting Mongrel => Rails 2.3.4 application starting on http://0.0.0.0:3000 /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:426:in `load_missing_constant': Expected /Users/Mister/dev/copy/app/controllers/admin/admin_controller.rb to define Admin::AdminController (LoadError) from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/inflector.rb:361:in `constantize' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/inflector.rb:360:in `each' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/inflector.rb:360:in `constantize' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/string/inflections.rb:162:in `constantize' from /opt/local/lib/ruby/gems/1.8/gems/hobo-1.0.0/lib/hobo/model_controller.rb:61:in `all_controllers' from /opt/local/lib/ruby/gems/1.8/gems/hobo-1.0.0/lib/hobo/model_controller.rb:57:in `each' from /opt/local/lib/ruby/gems/1.8/gems/hobo-1.0.0/lib/hobo/model_controller.rb:57:in `all_controllers' from /opt/local/lib/ruby/gems/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:97:in `add_routes_for' from /opt/local/lib/ruby/gems/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:83:in `add_routes' from /opt/local/lib/ruby/gems/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:83:in `each' from /opt/local/lib/ruby/gems/1.8/gems/hobo-1.0.0/lib/hobo/model_router.rb:83:in `add_routes' from /opt/local/lib/ruby/gems/1.8/gems/hobo-1.0.0/rails/../lib/hobo.rb:73:in `add_routes' from /Users/Mister/dev/copy/config/routes.rb:6 from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:226:in `draw' from /Users/Mister/dev/copy/config/routes.rb:1 from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in `load' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in `load' from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:286:in `load_routes!' from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:286:in `each' from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:286:in `load_routes!' from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:266:in `reload!' from /Users/Mister/.gem/ruby/1.8/gems/rails-2.3.4/lib/initializer.rb:537:in `initialize_routing' from /Users/Mister/.gem/ruby/1.8/gems/rails-2.3.4/lib/initializer.rb:188:in `process' from /Users/Mister/.gem/ruby/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send' from /Users/Mister/.gem/ruby/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run' from /Users/Mister/dev/copy/config/environment.rb:11 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' from /Users/Mister/.gem/ruby/1.8/gems/rails-2.3.4/lib/commands/server.rb:84 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./script/server:3 the environment and gem in the app: RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION ENV['RAILS_ENV'] ||= 'development' config.gem 'hobo' config.gem "RedCloth", :version => ">= 4.2.2" config.gem "authlogic" config.gem "cancan" config.gem "jrails" config.gem "peteonrails-vote_fu", :source => "http://gems.github.com", :lib => "vote_fu" routes: map.site_search 'search', :controller => 'admin/front', :action => 'search' map.admin '/admin', :controller => 'admin/front', :action => 'index' Hobo.add_routes(map)

    Read the article

  • ruby super keyword

    - by ash34
    Hi, From what I understand, 'super' keyword invokes a method with the same name as the current method in the superclass of the current class. Below in the autoload method, there is a call to 'super'. I would like to know in which superclass I would find a method with the same name or what does the call to 'super' do module ActiveSupport module Autoload ... def autoload(const_name, path = @@at_path) full = [self.name, @@under_path, const_name.to_s, path].compact.join("::") location = path || Inflector.underscore(full) if @@eager_autoload @@autoloads[const_name] = location end super const_name, location end .... end end module ActiveRecord extend ActiveSupport::Autoload ... autoload :TestCase autoload :TestFixtures, 'active_record/fixtures' end This code is from the rails master branch. Thanks much.

    Read the article

  • How can I prevent Rails from "pluralizing" a column name?

    - by Mike
    I'm using dwilkie's foreigner plugin for rails. I have a table creation statement that looks like: create_table "agents_games", :force => true, :id => false do |t| t.references :agents, :column => :agent_id, :foreign_key => true, :null => false t.references :games, :column => :game_id, :foreign_key => true, :null => false end However, this generates the following SQL: [4;35;1mSQL (2.7ms)[0m [0mCREATE TABLE "agents_games" ("agents_id" integer NOT NULL, "games_id" integer NOT NULL) [0m I want the columns to be called agent_id and game_id - not agents_id and agent_id. How can I prevent Rails from pluralizing the columns? I tried the following in my enviornment.rb file, which didn't help: ActiveSupport::Inflector.inflections do |inflect| inflect.uncountable "agent_id", "game_id" end

    Read the article

  • Kohana ORM Aliasing and "Trying to get property of non-object"

    - by Toto
    I have the following tables in the database: teams: id name matches: id team1_id team2_id I've defined the following ORM models in my Kohana application: class Match_Model extends ORM { protected $belongs_to = array('team1_id' => 'team', 'team2_id' => 'team'); } class Team_Model extends ORM { protected $has_many = array('matches'); } The following code in a controller: $match = ORM::factory('match',1); echo $match->team1_id->name; /* <-- */ Is throwing the following error on the linke marked with /* <--- */: Trying to get property of non-object The framework is yielding the value of the foreign key instead of a reference to a Match_Model instance as it should (giving the has_many and belongs_to properties stated). Am I missing something? Note: Just in case, I've added the irregular plural 'match' => 'matches' in application/config/inflector.php

    Read the article

  • Javascript not executing (I included format.js)

    - by Brandon
    I added format.js to my controller, yet I still cannot get the js in index.js.erb to execute when I view my index page. The only thing I can figure out is that it must be because of the model name. I had to add ActiveSupport::Inflector.inflections do |inflect| inflect.irregular 'business', 'businesses' end to my inflections.rb file...because my model is called Business. my views/js are located at views/businesses/* Please help before I pull my hair out! All I have in the index.js.erb file is: alert(1); Obviously the goal is that I will get an alert when I finally get the issue fixed, letting me know it is working.

    Read the article

  • Why don't RSpec's methods, "get", "post", "put", "delete" work in a controller spec in a gem (or out

    - by ramon.tayag
    I'm not new to Rails or Rspec, but I'm new to making gems. When I test my controllers, the REST methods "get", "post", "put", "delete" give me an undefined method error. Below you'll find code, but if you prefer to see it in a pastie, click here. Thanks! Here's my spec_helper: $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rubygems' require 'active_support' unless defined? ActiveSupport # Need this so that mattr_accessor will work in Subscriber module require 'active_record/acts/subscribable' require 'active_record/acts/subscriber' require 'action_view' require 'action_controller' # Since we'll be testing subscriptions controller #require 'action_controller/test_process' require 'spec' require 'spec/autorun' # Need active_support to user mattr_accessor in Subscriber module, and to set the following inflection ActiveSupport::Inflector.inflections do |inflect| inflect.irregular 'dorkus', 'dorkuses' end require 'active_record' # Since we'll be testing a User model which will be available in the app # Tell active record to load the subscribable files ActiveRecord::Base.send(:include, ActiveRecord::Acts::Subscribable) ActiveRecord::Base.send(:include, ActiveRecord::Acts::Subscriber) require 'app/models/user' # The user model we expect in the application require 'app/models/person' require 'app/models/subscription' require 'app/models/dorkus' require 'app/controllers/subscriptions_controller' # The controller we're testing #... more but I think irrelevant My subscriptions_spec: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe SubscriptionsController, "on GET index" do load_schema describe ", when only subscribable params are passed" do it "should list all the subscriptions of the subscribable object" end describe ", when only subscriber params are passed" do it "should list all the subscriptions of the subscriber" do u = User.create d1 = Dorkus.create d2 = Dorkus.create d1.subscribe! u d2.subscribe! u get :index, {:subscriber_type = "User", :subscriber_id = u.id} assigns[:subscriptions].should == u.subscriptions end end end My subscriptions controller: class SubscriptionsController The error: NoMethodError in 'SubscriptionsController on GET index , when only subscriber params are passed should list all the subscriptions of the subscriber' undefined method `get' for # /home/ramon/rails/acts_as_subscribable/spec/controllers/subscriptions_controller_spec.rb:21:

    Read the article

  • rails with fcgi error

    - by qichunren
    LoadError (Expected /web/zhao_backend2/app/controllers/admin_controller.rb to define AdminController): /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:249:in load_missing_constant' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:inconst_missing' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in const_missing' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:inconstantize' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in constantize' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1426:inrecognize' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in handle_request' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:indispatch' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in dispatch_cgi' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:indispatch' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:101:in process_request' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:149:inwith_signal_handler' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:99:in process_request' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:77:inprocess_each_request' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/fcgi-0.8.8/lib/fcgi.rb:612:in each_cgi' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/fcgi-0.8.8/lib/fcgi.rb:609:ineach' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/fcgi-0.8.8/lib/fcgi.rb:609:in each_cgi' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:76:inprocess_each_request' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:50:in process!' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:24:inprocess!' /public/dispatch.fcgi:24 Rendering /web/zhao_backend2/public/500.html (500 Internal Server Error)

    Read the article

  • Loading a helper elsewhere than the autoload.php?

    - by drpcken
    I inherited a project and I'm cleaning up a bit and trying to finish it. I noticed that they used (or wrote) a breadcrumb helper. It is in my helpers folder and is named breadcrumb_helper.php It has a single function to build a breadcrumb menu with links and pass it to the view breadcrumbs.php. Here's the code: function show_breadcrumbs() { $ci =& get_instance(); $ci->load->helper('inflector'); $data = ''; //build breadcrumb and store in $data $this->load->view("breadcrumbs", $data) } I was trying to figure out how this helper worked and I checked the autoload.php but there is no reference to the helper in there. In face here is my autoload: $autoload['helper'] = array('url','asset','combine','navigation','form','portfolio','cookie','default'); This show_breadcrumbs() function is used quite a bit in some of my pages so I'm confused as to how its loading if it isn't in the autoloader. It is called like this in a few of my pages: <?=show_breadcrumbs()?> What am I missing? Why isn't this in my autoload? I even did a global search and couldn't find anywhere the helper is being loaded.

    Read the article

1